1

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.

devin
  • 1,246
  • 3
  • 20
  • 27

3 Answers3

3

VIM 'ftplugins' are there exactly for this purpose.

http://vimdoc.sourceforge.net/htmldoc/usr_43.html#filetype-plugin

Jacek Konieczny
  • 3,777
  • 2
  • 23
  • 22
0

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
MikeyB
  • 39,291
  • 10
  • 105
  • 189
0

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.

Martian
  • 1,100
  • 8
  • 8