mirror of
https://github.com/jbranchaud/til
synced 2026-01-05 16:18:01 +00:00
Add List autocmds Configured For The Current Buffer as Vim TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1265 TILs and counting..._
|
||||
_1266 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1369,6 +1369,7 @@ _1265 TILs and counting..._
|
||||
- [Jump To Matching Pair](vim/jump-to-matching-pair.md)
|
||||
- [Jump To The Next Misspelling](vim/jump-to-the-next-misspelling.md)
|
||||
- [List All Buffers](vim/list-all-buffers.md)
|
||||
- [List autocmds Configured For The Current Buffer](vim/list-autocmds-configured-for-the-current-buffer.md)
|
||||
- [List Of Plugins](vim/list-of-plugins.md)
|
||||
- [Load A Directory Of Files Into The Buffer List](vim/load-a-directory-of-files-into-the-buffer-list.md)
|
||||
- [Make Directories For The Current File](vim/make-directories-for-the-current-file.md)
|
||||
|
||||
34
vim/list-autocmds-configured-for-the-current-buffer.md
Normal file
34
vim/list-autocmds-configured-for-the-current-buffer.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# List autocmds Configured For The Current Buffer
|
||||
|
||||
Vim itself and many of the plugins you use will configure `autocmd` triggers.
|
||||
This are commands that get executed when a certain editor event takes place in
|
||||
certain types of files.
|
||||
|
||||
A common example is having a tool like `prettier` configured to format the
|
||||
contents of JavaScript files when the `BufWritePost` event happens, that is,
|
||||
right after the buffer gets written.
|
||||
|
||||
You can list each `autocmd` that is configured for your current buffer using
|
||||
`:au` and a couple arguments.
|
||||
|
||||
```
|
||||
:au * <buffer>
|
||||
```
|
||||
|
||||
The `*` says match against all events. The `<buffer>` filters them down to just
|
||||
what is configured for the current buffer.
|
||||
|
||||
If you just wanted to know about `BufWritePost` events for the current buffer,
|
||||
try this.
|
||||
|
||||
```
|
||||
:au BufWritePost <buffer>
|
||||
```
|
||||
|
||||
Or if you want to know about buffer number `4`:
|
||||
|
||||
```
|
||||
:au BufWritePost <buffer=4>
|
||||
```
|
||||
|
||||
See `:h :au` for more details.
|
||||
Reference in New Issue
Block a user