vim-autoformat/plugin/autoformat.vim
2012-09-30 22:26:51 +02:00

17 lines
898 B
VimL

"Set the format programs for the right filetypes
au filetype javascript let &formatexpr="JsBeautify()"
au filetype html let &formatexpr="HtmlBeautify()"
au filetype css let &formatexpr="CSSBeautify()"
au filetype php let &formatprg="phpCB --space-after-if --space-after-switch --space-after-while --space-before-start-angle-bracket --space-after-end-angle-bracket --one-true-brace-function-declaration --glue-amperscore --change-shell-comment-to-double-slashes-comment --force-large-php-code-tag --force-true-false-null-contant-lowercase --align-equal-statements --comment-rendering-style PEAR --equal-align-position 50 --padding-char-count 4"
"Function for formatting the entire buffer
function g:VimAutoformat()
"Save window state
let winview=winsaveview()
"Autoformat code
:silent exe "normal gggqG"
"Recall window state
call winrestview(winview)
endfunction