If it's okay to configure the local exceptions centrally, you can put such autocmds into your
: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
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