2012-09-30 22:11:36 +02:00
|
|
|
"Function for formatting the entire buffer
|
2012-10-10 01:04:23 +02:00
|
|
|
function! g:Autoformat()
|
2012-12-01 14:06:28 +01:00
|
|
|
"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 22:11:36 +02:00
|
|
|
endfunction
|