vim-autoformat/plugin/autoformat.vim

19 lines
451 B
VimL
Raw Normal View History

2012-09-30 16:11:36 -04:00
"Function for formatting the entire buffer
2012-12-02 09:27:50 -05:00
function! s:Autoformat()
"If a formatprg is specified
if &formatprg!=""
"echo "formatprg is: ".&formatprg
"Save window state
let winview=winsaveview()
"Autoformat code
:silent exe "normal gggqG"
"Recall window state
call winrestview(winview)
else
echo "No formatter installed for this filetype"
endif
2012-09-30 16:11:36 -04:00
endfunction
2012-12-02 09:27:50 -05:00
"Create a command for this
2012-12-02 09:33:03 -05:00
command! Autoformat call s:Autoformat()