diff --git a/autoload/shfmt.vim b/autoload/shfmt.vim index b5c790e..ae99480 100644 --- a/autoload/shfmt.vim +++ b/autoload/shfmt.vim @@ -14,7 +14,7 @@ function! shfmt#shfmt(current_args, line1, line2) abort " we've erased the user's work! undo endif - " Reset the cursor position if we moved + " Reset the cursor position if we moved if l:cursor_position != getcurpos() call setpos('.', l:cursor_position) endif diff --git a/plugin/shfmt.vim b/plugin/shfmt.vim index 56f9066..f93b92b 100644 --- a/plugin/shfmt.vim +++ b/plugin/shfmt.vim @@ -34,16 +34,14 @@ function! s:ShfmtSwitches(...) return join(s:shfmt_switches, "\n") endfunction -command! -range=% -complete=custom,s:ShfmtSwitches -nargs=? Shfmt :call shfmt#shfmt(, , ) +command! -bar -range=% -complete=custom,s:ShfmtSwitches -nargs=? Shfmt :call shfmt#shfmt(, , ) augroup shfmt autocmd! - if get(g:, 'shfmt_fmt_on_save', 1) - " Use BufWritePre to filter the file before it's written since we're - " processing current buffer instead of the saved file. - autocmd BufWritePre *.sh Shfmt - autocmd FileType sh autocmd BufWritePre Shfmt - endif + " Use BufWritePre to filter the file before it's written since we're + " processing current buffer instead of the saved file. + autocmd BufWritePre *.sh if get(g:, 'shfmt_fmt_on_save', 1) | Shfmt | endif + autocmd FileType sh autocmd BufWritePre if get(g:, 'shfmt_fmt_on_save', 1) | Shfmt | endif augroup END let &cpo = s:save_cpo