2

Let's say I rename a augroup in my vimrc; what happens then? Do the autocmds inside that augroup get loaded twice? For example, let's say I rename the following augroup

augroup testgroup
    autocmd!
    autocmd BufWrite * :sleep 200m
    autocmd BufWrite * :echom "Foo"
    autocmd BufWrite * :echom "Bar"
augroup END

as

augroup TestGroup
    autocmd!
    autocmd BufWrite * :sleep 200m
    autocmd BufWrite * :echom "Foo"
    autocmd BufWrite * :echom "Bar"
augroup END
3

Your vimrc file is normally only loaded once per vim session. So if you change the file and rename the augroup, nothing happens in your running vim instance.

If you :source $MYVIMRC after you changed it you will end up with two versions of each of these autocommands. One in each group. To see which autocommands are defined you can execute

:au                "lists all autocommands (potentially very many)
:au BufWrite      " lists all autocommands for the BufWrite event
:au testgroup     " lists all autocommands in the group "testgroup"    
:au TestGroup     " lists all autocommands in the group "TestGroup"

In order to remove all autocommads of the "testgroup" in a running vim instance you can execute :au! testgroup.

You can start reading at :h :au.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.