I am trying to enable .xml
syntax highlighting in Vim for .xaml
files since .xaml
files don't have syntax highlighting of its own. I came across a post on Stack Overflow which recommended to use au BufNewFile,BufRead *.xaml setf xml
but that did not provide syntax highlighting as soon as I open the .xaml
file. I can see below on the console that the .xaml
files are changed to .xml
filetype.
I tried what this post suggested: autocmd BufEnter *.xaml :setlocal filetype=xml
but this does not provide syntax highlighting either.
I even tried modifying it to: autocmd BufEnter *.xaml :setlocal filetype=xml | syntax on
but it causes several glitches and formats the syntax higlighting of all my other open tabs & windows as .xml
. Any suggestions are deeply appreciated. Thank you!
syntax on
(if you must, usesyntax enable
). Does syntax highlighting work for.xml
files? What filetype is reported in a.xml
file? The best way to add simple filetype rules is to create a file~/.vim/ftdetect/xaml.vim
withautocmd BufRead,BufNewFile *.xaml setfiletype xml
, though sometimes you wantset filetype=xml
instead. Can you edit to answer these questions and clarify what "it does not behave…" or "syntax highlighting does not function" mean?.xml
files? What is their filetype?.xml
syntax highlighting does work but I have to enable it while in vim, I have to:set filetype=xml
& then:syntax on/enable
. This way, I do get proper syntax highlighting for '.xaml' files as well.