Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion autoload/shfmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 5 additions & 7 deletions plugin/shfmt.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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(<q-args>, <line1>, <line2>)
command! -bar -range=% -complete=custom,s:ShfmtSwitches -nargs=? Shfmt :call shfmt#shfmt(<q-args>, <line1>, <line2>)

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 <buffer> 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 <buffer> if get(g:, 'shfmt_fmt_on_save', 1) | Shfmt | endif
augroup END

let &cpo = s:save_cpo