Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using vim to browse through some log files (the file extension is .log) which contain a lot of XML.

How can I turn on XML syntax highlighting after opening the file? Of course, I don't actually want to associate XML syntax highlighting with all log files.

share|improve this question
add comment

2 Answers 2

up vote 5 down vote accepted

The command you want is ":setfiletype". For example:

:setf xml

See ":help :setfiletype".

share|improve this answer
    
Beautiful, this is exactly what I was looking for. Thanks! –  Mansoor Siddiqui Jan 27 '12 at 22:42
add comment

You can place this in your ~/.vimrc file as well

au BufNewFile, BufRead *.extension_name set filetype=xml

Replace extension_name with the extension you want, reopen vim, and you will see xml syntax highlight.

share|improve this answer
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.