当前位置:   article > 正文

VSCode格式化shell脚本_effective shfmt flags: -i=4

effective shfmt flags: -i=4

安装格式化插件:shell-format

VSCode打开shell脚本之后,按格式化快捷键Ctrl+Alt+F,会提示没有格式化shell的工具,然后安装插件,我装的是这个插件:shell-format

在这里插入图片描述

介绍:https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format

GitHub:https://github.com/mvdan/sh

在这里插入图片描述

在这里插入图片描述

用法

  • Ctrl+Alt+F
  • 右键 --> 格式化文档

插件不生效问题排查及处理

安装成功后,尝试格式化好几次,都没有生效,然后发现控制台有报错:

shfmt hasn't downloaded yet!Error: ENOENT: no such file or directory, stat 'c:\Users\Administrator\.vscode\extensions\foxundermoon.shell-format-7.2.5\bin\shfmt_v3.6.0_windows_amd64.exe'
Shfmt will be downloaded automatically!
download url: https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_windows_amd64.exe
download to: c:\Users\Administrator\.vscode\extensions\foxundermoon.shell-format-7.2.5\bin\shfmt_v3.6.0_windows_amd64.exe
If the download fails, you can manually download it to the dest directory.
Or download to another directory, and then set the "shellformat.path" as the path
download shfmt page: https://github.com/mvdan/sh/releases
You can't use this plugin until the download is successful.
Effective shfmt flags: -i=4
Effective shfmt flags: -i=4
Effective shfmt flags: -i=4
Effective shfmt flags: -i=4
Effective shfmt flags: -i=4
Effective shfmt flags: -i=4
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

原来又是偶尔连不上GitHub导致不能下载这个文件:https://github.com/mvdan/sh/releases/download/v3.6.0/shfmt_v3.6.0_windows_amd64.exe,尝试重连,不行再用加速网站尝试:https://ghproxy.com/,下载成功后,放到报错提示的路径下,然后就可以正常格式化了。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/659644
推荐阅读
相关标签
  

闽ICP备14008679号