Skip to content

Instantly share code, notes, and snippets.

@alexisbellido
Created October 23, 2015 15:24
Show Gist options
  • Save alexisbellido/d07003da0a3f780cb7c1 to your computer and use it in GitHub Desktop.
Save alexisbellido/d07003da0a3f780cb7c1 to your computer and use it in GitHub Desktop.
My .vimrc to alternate between WordPress, Drupal, HTML and Javascript coding (always work in progress)
"set shiftwidth=2
"set expandtab
set nowrapscan
set autoindent
set smarttab
" Wordpress
" set autoindent
" set cindent
" "set shiftwidth=8
" set noexpandtab
" set nowrapscan
" set smarttab
"
autocmd Filetype php setlocal shiftwidth=8
autocmd Filetype html setlocal shiftwidth=2
autocmd Filetype javascript setlocal shiftwidth=2
" Try this one
"autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP autoindent shiftwidth=8 softtabstop=4 tabstop=4 noexpandtab
"set foldmethod=indent
filetype on
filetype plugin on
colorscheme desert
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