Generally speaking, that's exactly what the :noautocmd
command modifier is for. Just prefix your command with that and all autocommands should be disabled for just the run of that command.
:noautocmd w
Of course, this is the scorched earth approach. If there are other autocommands that you need to keep enabled and you're trying to ignore just the one you mentioned than a different approach is required. If this is the case I'd suggest explicitly mentioning it in your question, though there are few things I can mention right now...
First, want to see which, if any, autocommands are being run? Try this:
:9verbose w
Speaking for myself, I have two plugins that have actions that are triggered by an autocommand associated with :w
. They aren't what I'd call critical but I may still want to keep them intact. They are not associated with BufWritePre
, though, so for me an alternative to :noautocmd
would be to disable just the BufWritePre
event, do the write, then re-enable that event:
:set eventignore+=BufWritePre | w | set eventignore-=BufWritePre
That could easily be wrapped up in a mapping or user command.