How to disable autocmd or augroup in vim?

Posted by Andrew Vit on Super User See other posts from Super User or by Andrew Vit
Published on 2012-06-20T02:51:31Z Indexed on 2012/06/21 9:19 UTC
Read the original article Hit count: 234

Filed under:
|
|

Given I have a group of commands such as:

augroup MyGroup
  autocmd CursorMoved * silent call MyCommandOne()
augroup END

I want to disable all the autocommands in MyGroup for a time and then re-enable it later.

Is there anything I can do with the group? Specifically, is there a way to disable the whole group at once? If not, what can I do to disable individual commands?

Looking at the help, I only see a few options:

  • augroup! will delete the whole group: I don't think this is right since I will want to re-enable it again. (But maybe there's a way to easily redefine the group again?)
  • :noautocmd will only disable the callbacks for a one-off invocation of a command. (And it disables all autocmds, not specified ones)
  • eventignore addresses the event binding, not the command: it sounds like it disables all bound commands for a given event, not just one command or a group I can specify.

How is this done?

© Super User or respective owner

Related posts about vim

Related posts about configuration