I work on a bunch of different projects, and some have different code standards than others. Some projects also have a slightly different directory structure, which might conflict with some of my CtrlP mappings.

To make sure everything always works the way I want it to, I use project specific .vimrc files.

How To

Vim allows for per-project configuration files, although this is turned off by default. To enable this, drop this line into your ~/.vimrc:

set exrc

If you enable this, it’s also a good idea to add this to the end of your ~/.vimrc to disable unsafe commands in your project-specific .vimrc files:

set secure

This will prevent :autocmd, shell and write commands from being run inside project-specific .vimrc files unless they’re owned by you.

Now you can write per-project .vimrc files like the following:

set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set nosmarttab

set textwidth=80

map <leader>gf :CtrlPClearAllCaches<cr> :CtrlP features_wip<cr>