Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

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

if &filetype==""
  setfiletype conf
endif
share|improve this answer
add comment

From within vim:

 :runtime! syntax/c.vim
share|improve this answer
    
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 stackoverflow.com/questions/2666551/… - it says e.g. au BufNewFile,BufRead * if &syntax == '' | set syntax=html | endif. –  ott-- May 21 '12 at 11:50
add comment

Your Answer

 
discard

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.