From d26be13cd4b5cc681c07f44513115425e86b7b09 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 7 Nov 2022 09:51:29 -0600 Subject: [PATCH] Add List autocmds Configured For The Current Buffer as Vim TIL --- README.md | 3 +- ...ocmds-configured-for-the-current-buffer.md | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 vim/list-autocmds-configured-for-the-current-buffer.md diff --git a/README.md b/README.md index 05ec151..6982f99 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/vim/list-autocmds-configured-for-the-current-buffer.md b/vim/list-autocmds-configured-for-the-current-buffer.md new file mode 100644 index 0000000..c53566b --- /dev/null +++ b/vim/list-autocmds-configured-for-the-current-buffer.md @@ -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 * +``` + +The `*` says match against all events. The `` 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 +``` + +Or if you want to know about buffer number `4`: + +``` +:au BufWritePost +``` + +See `:h :au` for more details.