diff --git a/after/plugin/shfmt.vim b/after/plugin/shfmt.vim new file mode 100644 index 0000000..46f0eec --- /dev/null +++ b/after/plugin/shfmt.vim @@ -0,0 +1,10 @@ +if exists('g:loaded_shfmt_wrapper') + finish +endif +let g:loaded_shfmt_wrapper = 1 + +function! SHFmt() + let save_pos = getpos(".") + execute "%!shfmt -s" + call setpos(".", save_pos) +endfunction diff --git a/vimrc b/vimrc index 9d2011c..fbd7962 100644 --- a/vimrc +++ b/vimrc @@ -1025,6 +1025,7 @@ let g:go_autodetect_gopath = 0 " au BufWritePre *.py,*.js :Autoformat +au FileType sh au BufWritePre :call SHFmt() " " Custom commands