If each project uses a distinct language, the built-in filetype plugin (ftplugin) mechanism, as described by Jamie Schembri, will work just fine. If you really need different settings for the same type of files, read on:
Central configuration
If it’s okay to configure the local exceptions centrally, you can put such autocmds into your ~/.vimrc
:
:autocmd BufRead,BufNewFile /path/to/dir/* setlocal ts=4 sw=4
On the other hand, if you want the specific configuration stored with the project (and don’t want to embed this in all files via modelines), you have the following two options:
Local config with built-in functionality
If you always start Vim from the project root directory, the built-in
:set exrc
enables the reading of a .vimrc
file from the current directory. You can place the :set ts=4 sw=4
commands in there.
Local config through plugin
Otherwise, you need the help of a plugin; there are several on vim.org; I can recommend the localrc plugin, which even allows local filetype-specific configuration.
Note that reading configuration from the file system has security implications; you may want to :set secure
.