Created
March 6, 2013 17:11
-
-
Save navasvarela/5101029 to your computer and use it in GitHub Desktop.
My .vimrc with PrettyXML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call pathogen#infect() | |
filetype plugin indent on | |
syntax on | |
set tabstop=4 | |
set shiftwidth=4 | |
set showmatch | |
set number | |
map <F3> <Esc>gg=G<CR> | |
imap <F3> <Esc>gg=G<CR> | |
map <F5> :w<CR>:!node %:p<CR> | |
imap <F5> <Esc>:w<CR>:!node %:p<CR> | |
map <F2> <Esc>:wqa<CR> | |
map <F6> <Esc>gg"*yG<CR> | |
nmap <F4> :w<CR>:make<CR>:cw<CR> | |
nmap <C-k> :tabprev<CR> | |
nmap <C-l> :tabnext<CR> | |
nmap <C-n> :tabnew<CR> | |
autocmd VimEnter * NERDTree | |
autocmd VimEnter * wincmd p | |
autocmd BufNewFile,BufRead *.json set ft=javascript | |
function! DoPrettyXML() | |
" save the filetype so we can restore it later | |
let l:origft = &ft | |
set ft= | |
" delete the xml header if it exists. This will | |
" permit us to surround the document with fake tags | |
" without creating invalid xml. | |
1s/<?xml .*?>//e | |
" insert fake tags around the entire document. | |
" This will permit us to pretty-format excerpts of | |
" XML that may contain multiple top-level elements. | |
0put ='<PrettyXML>' | |
$put ='</PrettyXML>' | |
silent %!xmllint --format - | |
" xmllint will insert an <?xml?> header. | |
" it's easy enough to delete | |
" if you don't want it. | |
" delete the fake tags | |
2d | |
$d | |
" restore the 'normal' | |
" indentation, which is one extra level | |
" too deep due to the extra tags we wrapped around the document. | |
silent %< | |
" back to home | |
1 | |
" restore the filetype | |
exe "set ft=" . l:origft | |
endfunction | |
command! PrettyXML call DoPrettyXML() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment