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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As far as I know, there isn’t really a difference between the two.
I prefer to put commands like that in
ftpluginand keep my main.vimrclanguage-agnostic… But there are no hard-and-fast rules. An advantage to keeping it in yourvimrcwould 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.vimrcwill 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.