diff --git a/ftplugin/hblang.vim b/ftplugin/hblang.vim index 2e07215..1753262 100644 --- a/ftplugin/hblang.vim +++ b/ftplugin/hblang.vim @@ -1,16 +1,18 @@ setlocal commentstring=//\ %s -function Hbformat() +function HBformat() silent! !hbc --fmt-stdout if v:shell_error echom "Errors in file" !hbc --fmt-stdout else + let save_cursor = getcurpos() silent! %!hbc --fmt-stdout + call setpos('.', save_cursor) endif endfunction augroup hblang_group autocmd! - autocmd BufWritePost *.hb :call Hbformat() + autocmd BufWritePost *.hb :call HBformat() augroup END