I use localvimrc for this purpose.
Put a .lvimrc
with your project settings inside your project and these settings will override settings in .vimrc
.
By default, you will be asked if you want to source this file, eg:
localvimrc: source /home/martin/code/.lvimrc? ([y]es/[n]o/[a]ll/[q]uit)
This is to prevent sourcing random (untrusted) vimrc files. If you find this annoying, you can setup a whitelist of .lvimrc
files with g:localvimrc_whitelist
:
let g:localvimrc_whitelist = '/home/martin/code/.lvimrc'
Or you can just disable asking for confirmation completely with ketset g:localvimrc_ask = 0
. This is not recommended, though.