How do I tell vim to automatically use a particular filetype (usually for syntax highlighting) when none is detected?
2 Answers
Add the following to the end of your ~/.vimrc
(change conf
to whichever filetype you would like as default):
if &filetype==""
setfiletype conf
endif
From within vim:
:runtime! syntax/c.vim
-
1To 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.– MikeyBMay 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