Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Several file extensions in VIM autocmd

Tags:

vim

rubocop

I got autocmd BufWrite *.rb :RuboCop -a in my ~/.vimrc

How to modify it to process *.jbuilder files as well?

like image 596
zuba Avatar asked May 13 '15 15:05

zuba


1 Answers

You can either add another file-glob, separated by ,:

autocmd BufWrite *.rb,*.jbuilder :RuboCop -a

This is documented under :help autocmd-patterns. Alternatively, of course, define a separate autocmd:

autocmd BufWrite *.rb :RuboCop -a
autocmd BufWrite *.jbuilder :RuboCop -a

If all these file globs already are detected to a single filetype inside Vim, you can also leverage that, and define a buffer-local trigger on that:

autocmd FileType ruby autocmd BufWrite <buffer> RuboCop -a
like image 84
Ingo Karkat Avatar answered Oct 01 '22 12:10

Ingo Karkat