January 2015
Beginner to intermediate
85 pages
1h 58m
English
An autocommand is a command, or a series of commands, that Vim automatically executes when a particular condition occurs. The conditions are called events, and Vim 7.4 includes more than 80 events, which we can trigger by doing anything from creating a new buffer to changing the color scheme to losing the user’s interest (see :help UserGettingBored). We can use autocommands to have Vim automatically execute code when a user loads a certain kind of file, set a setting to a specific value, or trigger some other kind of event.
Let’s look at an example. This is a very basic autocommand:
| | autocmd VimLeave * echo 'Bye!' | sleep 1000m |
The keyword is autocmd. Following the keyword is the event name, VimLeave ...
Read now
Unlock full access