Home > Uncategorized > Vim syntax for xaml files

Vim syntax for xaml files

So you’re using Windows and want to edit your xaml files every once in a while with vi/vim/gvim, but vim doesn’t recognize xaml as an xml file and doesn’t give you nice syntax highlighting? Simple fix. In your home directory, create a vimfiles/ftdetect/myrules.vim file with the following contents:

" We set the type to XML only if no type was detected yet au BufRead,BufNewFile *.xaml setfiletype xml " OR unconditionally "au BufRead,BufNewFile *.xaml set filetype=xml
Categories: Uncategorized Tags: , ,
  1. Samantha Bordeau
    September 29th, 2009 at 22:14 | #1

    Would throwing this at the bottom of your source file not also work?
    <!– vim: tw=120 ts=4 sw=4 et enc=utf8 syn=xml –>


  2. Gabriel Burca
    September 29th, 2009 at 22:24 | #2

    @Samantha Bordeau
    Yes, using that modeline would work as well. You would have to do it for every xaml file though. If you set up the file type detection in vim you only have to do it once and it applies to all xaml files.

  1. No trackbacks yet.