Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way where I can set vim to configure itself based on the filetype? So for example, text files have the equivalent of

:set spell :syntax off

Where a C source file has

:syntax on :smartindent on

Thanks for any help.

share|improve this question

VIM 'ftplugins' are there exactly for this purpose.

share|improve this answer

I like my python files correct, so my .vimrc has:

augroup filetypedetect
        au BufNewFile,BufRead *.py set ts=4 sw=4 et ai
augroup END
share|improve this answer

You should use :setl[ocal] instead of :set for things like ts, sw, et and ai.

However some things are global and can not be set per buffer and :syntax is one of them. You may try this to turn syntax off for current file:

:setl ft=

And as Jacek has pointed out ftplugins are the way.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.