1)文件 —> 首选项
因为 vscode 默认启用了根据文件类型自动设置tabsize的选项,在设置中添加:
?| 1 |
"editor.detectindentation": false
|

2)编辑器配置
在项目文件中新建 .editorconfig 文件
为特定类型文件指定缩进大小、缩进类型(空格,或tab),是否自动插入末行等等。
| 1 2 3 4 5 6 7 8 9 10 11 12 |
root = true
[*]
charset = utf-8
indent_style = tab
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false
|
3)安装 vscode 格式化代码插件
搜索并安装 beautify 格式化代码插件

使用指南:
打开要格式化的文件 —> f1 —> beautify file —> 选择你要格式化的代码类型


4)格式化对齐快捷键:
- windows: ctrl + k + f
- windows:shift + alt + f
- mac: shift + option + f
- ubuntu: ctrl + shift + i
到此这篇关于vscode 格式化缩进代码的实现的文章就介绍到这了,更多相关vscode 格式化缩进内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!
原文链接:https://blog.csdn.net/u013451157/article/details/79502754








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。