Per-Project settings for Vim
It is often desirable to have per-project settings in Vim. This can be achieved in multiple ways. One way is to define an autocmd for switching settings, based on the file path, another one is to override the settings per folder.
Defining a Vim command to set project specific settings
The solution described below takes another approach. It defines a Vim command, Pxyz, for project xyz which has to be called by the use when he wants to reconfigure Vim for a given project. Add a command like this to your $HOME/.vimrc (please note that a user-defined command must start with an uppercase letter):
"for project xyz, change the working directory; that project uses SCons as
"build system and the tags file is not in the top directory.
command Pxyz :cd /path/to/pxyz/|:set makeprg=scons|:set tags=build/Debug/tags
This command sets the working directory and redefines the makeprg and tags variables. Different commands can be chained and are separated by a horizontal pipe character
Now you can now fire up Vim, type :Pxyz and start hacking away. You can define many commands, one for each project you are working on.
Separate config file per project
As you get more and more configurations you might decide to save them in a file and have the Vim command source that file.
Assuming you have a configuration file path/to/pxyz/project.vim, then the Pxyz command can simply source it:
command Pxyz :cd path/to/pxyz|:source project.vim
This has the advantage that you can check in the configuration file project.vim with your project. If the project.vim is checked in to the projects revision control system, then it is important to place the cd path/to/pxyz command in your $HOME/.vimrc file and not in the version control system: other users might want to place the project in a different path.