Last Updated: February 25, 2016
·
310
· chiggins

Specific vim settings for certain files in directory

Sometimes you work on a project and they have specific tabbing requirements than what your vim setup is used to. You don't want to change your global settings to match their requirements, but you can have setting specific to certain files in certain directories.

For example, the Metasploit project has certain tab requirements that are different than what I have set. Whenever I clone down the project from Github, it's always in the directory "metasploit-framework". So I added the following to my .vimrc file, and voila!

au! BufRead,BufNewFile */metasploit-framework/*.rb setlocal shiftwidth=4 tabstop=4 softtabstop=4
au! BufRead,BufNewFile */metasploit-framework/*.rb setlocal textwidth=78
au! BufRead,BufNewFile */metasploit-framework/*.rb setlocal noexpandtab