I have some 1000 lines shell script with all the kepywords
if/else, while, HERE document
Can anyone tell the best way to format the script, so the script looks good.
I was trying VG= in vim but that displaces HERE document content as well.
I have some 1000 lines shell script with all the kepywords
if/else, while, HERE document
Can anyone tell the best way to format the script, so the script looks good.
I was trying VG= in vim but that displaces HERE document content as well.
check this https://github.com/mvdan/sh, here is the sample command for indent with two spaces
shfmt -i 2 -w yourscript
By default the gg=G
gives you 8 tab spaces. To reduce the 8 tab spaces to 3 spaces edit your .vimrc
file:
set tabstop=3
set shiftwidth=3
set expandtab
This SO question qives you a good, in context discussion of everything gg=G
related.
PyCharm's BashSupport plugin now has an experimental bash
code formatter.
Sadly the BashSupport plugin "will only receive fixes for major problems" as of 2017.
I found a VSCode plugin based on https://github.com/mvdan/sh , support the .sh .bash Dockerfile .gitignore .properties /etc/hosts ...
Homepage:
https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format
macOS usage:
shift
+option
+f
or
shift
+command
+p
then type Format Document