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
:noautocmdor 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
:noasaves keystrokes::noa bufdo update - Especially useful inside
autocmdhandlers or scripts where you control many buffers - Combine with
:silentto 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