vim-autoformat/plugin/autoformat.vim

17 lines
898 B
VimL
Raw Normal View History

2012-09-30 16:11:36 -04:00
"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
2012-09-30 16:26:51 -04:00
function g:VimAutoformat()
2012-09-30 16:11:36 -04:00
"Save window state
let winview=winsaveview()
"Autoformat code
:silent exe "normal gggqG"
"Recall window state
call winrestview(winview)
endfunction