How to Have Language-Specific Settings in Vim
I wanted to set up Vim so that Coffeescript files would use 2 spaces for indentation. This was very simple:
- Create a file at
~/.vim/ftplugin/<language>.vim
where<language>
is the language you want to modify. For Coffeescript, this iscoffee
. The language name you should use is just the file extension. - In this file, add your settings. In my
coffee.vim
, I havesetlocal tabstop=2
andsetlocal shiftwidth=2
to make my tabs 2 spaces. - Open up a file in that language and enjoy your language specific settings!
Thanks for reading my post! If you enjoyed it or it helped you, please consider liking/tweeting this page, commenting, or following me on GitHub or Twitter!