Sign up ×
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

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

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

Your Answer


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.