3

How do I tell vim to automatically use a particular filetype (usually for syntax highlighting) when none is detected?

MikeyB
  • 39,291
  • 10
  • 105
  • 189

2 Answers2

4

Add the following to the end of your ~/.vimrc (change conf to whichever filetype you would like as default):

if &filetype==""
  setfiletype conf
endif
MikeyB
  • 39,291
  • 10
  • 105
  • 189
3

From within vim:

 :runtime! syntax/c.vim
ott--
  • 1,091
  • 1
  • 11
  • 13
  • 1
    To be clear, this answer is for setting a filetype automatically when none is detected. This just sets the syntax to a C file at runtime. – MikeyB May 20 '12 at 17:44
  • @MikeyB See http://stackoverflow.com/questions/2666551/vim-default-syntax-for-files-with-no-extension - it says e.g. `au BufNewFile,BufRead * if &syntax == '' | set syntax=html | endif`. – ott-- May 21 '12 at 11:50