Project-Specific Vim Configuration

Haoxiang Li bio photo By Haoxiang Li

Usually, we have our own vim configuration in the file ~/.vimrc What if we want one for our project? For example, we are working on certain project which needs to read in a tags file. Well, here is a possible solution.

You put a line at then end of your ~/.vimrc file

source ./.project.vim

Then for each project, put your project-specific stuff in a the file “.project.vim”.

If you don’t want the error message says vim cannot find the file “.project.vim”, wrap the line above with an if statement:

if filereadable("./.project.vim")
    source ./.project.vim
endif

:]