From f53a1526417493746d771f6243f30ba62ef7438c Mon Sep 17 00:00:00 2001
From: Max Christian Pohle
Date: Tue, 28 Feb 2017 22:14:43 +0100
Subject: improved xml handling

---
 vimrc | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

(limited to 'vimrc')

diff --git a/vimrc b/vimrc
index 48f8435..2217daa 100644
--- a/vimrc
+++ b/vimrc
@@ -209,6 +209,7 @@ inoremap <C-Space> <C-x><C-o>
 vnoremap < <gv|                   " allows deindenting a selected block and keeps selection
 vnoremap > >gv|                   " allows indenting a selected block and keeps selection
 
+
 " Bind CTRL+Backspace to vims version (CTRL+W) in " <CR> insert mode (only works with gvim)
 inoremap
       \ <C-Backspace>
@@ -257,6 +258,7 @@ set nocursorcolumn            | " turn visual cursor column off (improves perfor
 set nocursorline              | " turn visual cursor line off (improves performance)
 set nrformats+=alpha          | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers
 set nofoldenable              | " disable code folding. I hate code folding
+set foldcolumn=4              | " if code folding gets used display it in the clutter bar, where line numbers live
 set relativenumber            | " relative line numbers can speed up navigation
 set noshowmode                | " because we are using some powerline derivat
 set nostartofline             | " when scrolling: do not move the cursor to column 1
@@ -366,9 +368,25 @@ if has("autocmd")
   " hitting K over a keyword shows a help in a buffer.
   " Here we define the commands used to look those keywords up
   " as per file type...
-  augroup keyword_lookups
+  augroup filetype_specific
     autocmd FileType python setlocal keywordprg=pydoc
     autocmd FileType vim    setlocal keywordprg=:help |.
+    autocmd FileType c,cpp  setlocal equalprg=clang-format
+
+    " keyboard mapping for xml alike languages
+    " Alt-Up : Move cursor up one tag
+    " Alt-Down: Move cursor down one tag
+    " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically)
+    autocmd Filetype html,htmldjango,xml
+      \ :nnoremap
+              \ <M-Down>
+              \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>|
+      \ :nnoremap
+              \ <M-Up>
+              \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>|
+      \ :nnoremap
+              \ <leader>=
+              \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat=
   augroup END
 
 
@@ -434,8 +452,7 @@ else
   nnoremap <leader>t :new +terminal<CR>
 endif
 
-
-
+nnoremap <leader>r :syntax sync fromstart
 
 " colorscheme base16-embers
 " colorscheme base16-flat
-- 
cgit v1.2.3