still intentionally left blank Anwo 11:46, October 15, 2009 (UTC)
still intentionally left blank --Anwo 10:18, March 31, 2011 (UTC)
There is so much material on this wiki ... before adding another redundant tip, I could as well fill my profile page first.
Autocommands accumulate
Edit
When the line below is executed several times, this many BufDelete autocmds will be installed:
:au BufDelete * let g:last_deleted_buf = expand("<abuf>")
You can check the situation with
:au BufDelete *
or
:au BufDelete
To REPLACE a previous definition, one normally adds a bang:
:au! BufDelete * let g:last_deleted_buf = expand("<abuf>")
Problem here is that existing (ungrouped) `BufDelete *' autocmds are replaced by our new one.
Wrap the autocmd into an augroup:
augroup MyBufferChecks
au! BufDelete * let g:last_deleted_buf = expand("<abuf>")
augroup End
or, alternatively:
augroup MyBufferChecks
augroup End
au! MyBufferChecks BufDelete * let g:last_deleted_buf = expand("<abuf>")
By providing an :augroup, all :autocmd actions are local to that group.