1" Vim filetype plugin file 2" Language: xml 3" Maintainer: Christian Brabandt <[email protected]> 4" Last Changed: May 08th, 2018 5" Repository: https://github.com/chrisbra/vim-xml-ftplugin 6" Previous Maintainer: Dan Sharp <dwsharp at users dot sourceforge dot net> 7" URL: http://dwsharp.users.sourceforge.net/vim/ftplugin 8 9if exists("b:did_ftplugin") | finish | endif 10let b:did_ftplugin = 1 11 12" Make sure the continuation lines below do not cause problems in 13" compatibility mode. 14let s:save_cpo = &cpo 15set cpo&vim 16 17setlocal commentstring=<!--%s--> 18" Remove the middlepart from the comments section, as this causes problems: 19" https://groups.google.com/d/msg/vim_dev/x4GT-nqa0Kg/jvtRnEbtAnMJ 20setlocal comments=s:<!--,e:--> 21 22setlocal formatoptions-=t 23setlocal formatoptions+=croql 24setlocal formatexpr=xmlformat#Format() 25 26" XML: thanks to Johannes Zellner and Akbar Ibrahim 27" - case sensitive 28" - don't match empty tags <fred/> 29" - match <!--, --> style comments (but not --, --) 30" - match <!, > inlined dtd's. This is not perfect, as it 31" gets confused for example by 32" <!ENTITY gt ">"> 33if exists("loaded_matchit") 34 let b:match_ignorecase=0 35 let b:match_words = 36 \ '<:>,' . 37 \ '<\@<=!\[CDATA\[:]]>,'. 38 \ '<\@<=!--:-->,'. 39 \ '<\@<=?\k\+:?>,'. 40 \ '<\@<=\([^ \t>/]\+\)\%(\s\+[^>]*\%([^/]>\|$\)\|>\|$\):<\@<=/\1>,'. 41 \ '<\@<=\%([^ \t>/]\+\)\%(\s\+[^/>]*\|$\):/>' 42endif 43 44" For Omni completion, by Mikolaj Machowski. 45if exists('&ofu') 46 setlocal ofu=xmlcomplete#CompleteTags 47endif 48command! -nargs=+ XMLns call xmlcomplete#CreateConnection(<f-args>) 49command! -nargs=? XMLent call xmlcomplete#CreateEntConnection(<f-args>) 50 51" Change the :browse e filter to primarily show xml-related files. 52if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") 53 let b:browsefilter="XML Files (*.xml)\t*.xml\n" . 54 \ "DTD Files (*.dtd)\t*.dtd\n" . 55 \ "XSD Files (*.xsd)\t*.xsd\n" . 56 \ "All Files (*.*)\t*.*\n" 57endif 58 59" Undo the stuff we changed. 60let b:undo_ftplugin = "setlocal commentstring< comments< formatoptions< formatexpr< " . 61 \ " | unlet! b:match_ignorecase b:match_words b:browsefilter" 62 63" Restore the saved compatibility options. 64let &cpo = s:save_cpo 65unlet s:save_cpo 66