For my project I am constantly edition ROS .launch files, which are some kind of xml.
If I want to use syntax highlighting for better readability, I used to type :set filetype=xml . Which works, but gets kinda annoying in case you’ve got to type it multiple times a day.
In case you want to open .launch files with xml syntax by default, create a file in your .vim-folder:
mkdir $HOME/.vim/ #create the folder in case it doesn't exist yet vim $HOME/.vim/filetype.vim #open it in vim
Change into insert mode (press i) and paste following code into it:
if exists("did_load_filetypes") finish endif augroup filetypedetect au! BufNewFile,BufRead *.launch setf xml augroup END
Thats’s it, after that your vim will change: