Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I use different .vimrc settings for different types of files?

different files settings types
0
Posted

How can I use different .vimrc settings for different types of files?

0

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

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123