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.xmlfiles? What filetype is reported in a.xmlfile? The best way to add simple filetype rules is to create a file~/.vim/ftdetect/xaml.vimwithautocmd BufRead,BufNewFile *.xaml setfiletype xml, though sometimes you wantset filetype=xmlinstead. Can you [edit] to answer these questions and clarify what "it does not behave…" or "syntax highlighting does not function" mean? – D. Ben Knoble Jul 26 '22 at 15:52.xmlfiles? What is their filetype? – D. Ben Knoble Jul 26 '22 at 17:09.xmlsyntax 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. – Jose Membreno Jul 26 '22 at 18:00