What is the difference between placing:
autocmd FileType ruby setlocal ts=2
in my ~/.vimrc
and placing:
setlocal ts=2
in ~/.vim/ftplugin/ruby.vim
?
If there is no difference, where should I place commands that are specific to one filetype?
As far as I know, there isn't really a difference between the two.
I prefer to put commands like that in ftplugin
and keep my main .vimrc
language-agnostic… But there are no hard-and-fast rules. An advantage to keeping it in your vimrc
would be that your vim settings would be easier to move around (ex, you could get all your vim settings on a new machine by simply copying your .vimrc
, instead of .vimrc
+ .vim
). Obviously putting them in your .vimrc
will also have a minor performance penalty (ie, they will be loaded + executed for every file, not just ruby files)… But I wouldn't really worry about that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With