Turning on XML syntax highlighting in vim for a non-XML file

syntax highlightingvim

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.

Best Answer

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

:setf xml

See ":help :setfiletype".

Related Question