There are a few ways to do this. All of them involve the use of autocommands. Try “:h autocommand” for more information. * You can define autocommands which do everything for you in your .vimrc file: au!BufRead *.c,*.cc,*.h set fo=croq cin noic au!BufEnter *.c,*.cc,*.h ab #i #include au BufEnter *.c,*.cc,*.h ab #d #define au BufEnter *.c,*.cc,*.h map _hello_world :”Hello World” au BufEnter *.c,*.cc,*.h normal _hello_world au!BufLeave *.c,*.cc,*.h unab #i | unab #d au BufLeave *.c,*.cc,*.h unmap _hello_world The “!” is used just in the first autocommand for each event (BufEnter, BufLeave, etc.). * Or you can define one autocommand for each file type which loads a specific .vimrc file containing the settings you require. autocmd BufNewFile *.tex read ~/.vim/texmodel autocmd BufEnter *.tex source ~/.vim/texrc autocmd BufLeave *.tex source ~/.vim/notexrc Remember that all settings that you modify in a BufEnter or BufNewFile event may need to be unset with a corresponding BufLeave e