3 homepage: https://github.com/z0mbix/vim-shfmt
5 vim-shfmt: a vim plugin for shfmt
8 To update (replacing the current version) run `webi vim-shfmt`.
12 `vim-shfmt` uses [shfmt](https://webinstall.dev/shfmt) to format your `bash`
15 Use `:Shfmt` to run manually (or just save the file with `:w`).
17 This plugin comes with reasonable defaults, which install to
18 `~/vim/plugins/shfmt.vim`:
21 let g:shfmt_extra_args = '-i 4 -sr -ci -s'
22 let g:shfmt_fmt_on_save = 1
25 ### How to install and configure manually
27 1. Clone `vim-shfmt` into your `~/.vim/pack/plugins/start`:
30 mkdir -p ~/.vim/pack/plugins/start/
31 git clone --depth=1 https://github.com/CHANGEME/EXAMPLE.git ~/.vim/pack/plugins/start/shfmt
34 2. Create the file `~/.vim/plugins/shfmt.vim`. Add the same contents as
35 <https://github.com/webinstall/webi-installers/blob/master/vim-shfmt/shfmt.vim>,
36 which will look something like this:
39 " ~/.vim/plugins/shfmt.vim
41 " 4 indents, space between redirects, indented case statements, simplify
42 let g:shfmt_extra_args = '-i 4 -sr -ci -s'
43 let g:shfmt_fmt_on_save = 1
45 " auto run on .sh and .bash files
49 autocmd BufWritePre *.sh,*.bash Shfmt
53 3. Update `~/.vimrc` to source that plugin:
55 " shfmt: reasonable defaults from webinstall.dev/vim-shfmt
56 source ~/.vim/plugins/shfmt.vim