vimtricks.wiki Concise Vim tricks, one at a time.

How do I temporarily disable all autocommands when running an Ex command?

Answer

:noautocmd {command}

Explanation

The :noautocmd prefix (abbreviated :noa) suppresses all autocommand events for the duration of the following command. This is invaluable when batch-processing files in scripts where plugin-triggered autocommands would be slow or cause unwanted side effects.

How it works

  • Prefix any Ex command with :noautocmd or the abbreviation :noa
  • All events (BufRead, BufWrite, BufEnter, FileType, etc.) are disabled for that one command
  • After the command completes, autocommands are automatically re-enabled

Example

A common use case is bulk saving buffers without triggering formatters or linters on every write:

:noautocmd bufdo update

Other practical uses:

" Open a log file without triggering LSP or syntax highlighting setup
:noautocmd e /var/log/syslog

" Source a file without firing BufEnter handlers
:noautocmd source ~/.vim/plugin/example.vim

" Change directory without triggering DirChanged hooks
:noautocmd cd /tmp

Tips

  • The short form :noa saves keystrokes: :noa bufdo update
  • Especially useful inside autocmd handlers or scripts where you control many buffers
  • Combine with :silent to suppress output too: :silent noautocmd bufdo update
  • Does not affect the autocommand that triggered the current event — only those that would fire as a side effect of the command

Next

How do I configure Vim's command-line tab completion to show all matches and complete to the longest common prefix?