diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index 2a01ea7..ac3c67e 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -118,9 +118,6 @@ function! s:TryFormatter() return 1 endif - " Save window state - let winview=winsaveview() - python << EOF import vim, subprocess, os from subprocess import Popen, PIPE @@ -145,15 +142,13 @@ else: vim.current.buffer[:] = stdoutdata.split('\n') EOF - " Recall window state - call winrestview(winview) - return 1 endfunction " Create a command for formatting the entire buffer -command! -nargs=? -range=% -complete=filetype Autoformat ,call s:TryAllFormatters() +" Save and recall window state to prevent vim from jumping to line 1 +command! -nargs=? -range=% -complete=filetype Autoformat let winview=winsaveview()|,call s:TryAllFormatters()|call winrestview(winview) " Functions for iterating through list of available formatters