Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Vim's autocmd from running on write just once

Tags:

vim

autocmd

I have the following line in my .vimrc to automatically beautify js files after I save them:

autocmd BufWritePost *.js :call JsBeautify()

I want this 99% of the time, but sometimes I just want to write without having this function called. Is there an easy way to do that?

like image 585
Vlad the Impala Avatar asked Dec 09 '16 23:12

Vlad the Impala


1 Answers

I guess you're looking for :noa.

Usage:

:noa w

Excerpt from help:

:noautocmd :noa

To disable autocommands for just one command use the ":noautocmd" command modifier. This will set 'eventignore' to "all" for the duration of the following command. Example:

:noautocmd w fname.gz

This will write the file without triggering the autocommands defined by the gzip plugin.

like image 123
Mateusz Piotrowski Avatar answered Sep 21 '22 22:09

Mateusz Piotrowski