简体   繁体   中英

format the shell script

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.

检查此https://github.com/mvdan/sh ,这是缩进两个空格的示例命令

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.

使用VIM添加以下参数以缩进整个文件

gg=G

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM