autocmd is an additive command, and you probably don't want this behaviour by default.
For example, if you re-source your
.vimrc a few times while editing it, vim can slow down.
If you now type
:autocmd BufWritePost *, you'll see both lines in the output, not just one. Both get executed.
To avoid this behaviour, surround all your
autocmds as follows:
Automatically source .vimrc after saving
Add this to your
echom tells the user what has happened (and also logs to
$MYGVIMRC handle platform-specific names for the configuration files,
- and only match the actual configuration files (ignoring copies in other directories, or a
has() will prevent an error if using incompatible versions, such as
autocmd! avoids buildup of multiple identical autocommands if this file is sourced again. (It clears all commands in the named group, so the group name is important.)
Refresh vimdiff views if a file is saved in another window
This modified text is an extract of the original Stack Overflow Documentation created by following contributors
and released under CC BY-SA 3.0