]> git.sthu.org Git - vimconf.git/commitdiff
xml: Add XML_reformat() function
authorStefan Huber <shuber@sthu.org>
Thu, 16 Apr 2020 06:42:35 +0000 (08:42 +0200)
committerStefan Huber <shuber@sthu.org>
Thu, 16 Apr 2020 06:42:35 +0000 (08:42 +0200)
This function pretty-prints the file.

ftplugin/xml.vim [new file with mode: 0644]
init.vim

diff --git a/ftplugin/xml.vim b/ftplugin/xml.vim
new file mode 100644 (file)
index 0000000..e72b00e
--- /dev/null
@@ -0,0 +1,9 @@
+if exists("b:did_ftplugin")
+    finish
+endif
+let b:did_ftplugin = 1
+
+" Pretty format the XML content by passing it through xmllint.
+function XML_reformat()
+    exec "%!xmllint --format -"
+endfunction
index f4b86e15bd31c35038a1255deb31810f8e3c7745..75f8c34f1c917612f5b0eaaf8848e0033497b0fe 100644 (file)
--- a/init.vim
+++ b/init.vim
@@ -60,6 +60,7 @@ runtime plugsetup.vim
 
 " Some preferences for indent detection
 let g:detectindent_min_indent = 2
+let g:detectindent_max_indent = 4
 let g:detectindent_preferred_indent = 4
 
 " Attention: Must be run after plugsetup.vim
@@ -172,7 +173,7 @@ au FileType markdown call RagtagInit()
 
 let g:detectspelllang_langs = {}
 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
-"au BufReadPost * :DetectIndent
+au BufReadPost *.java :DetectIndent
 
 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'