3

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

2 Answers 2

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
3

From within vim:

 :runtime! syntax/c.vim
2
  • 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, 2012 at 17:44
  • @MikeyB See stackoverflow.com/questions/2666551/… - it says e.g. au BufNewFile,BufRead * if &syntax == '' | set syntax=html | endif.
    – ott--
    May 21, 2012 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .