欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > > 文章正文

【VSCode】格式化缩进代码,vscode格式化缩进

来源: javaer 分享于  点击 17435 次 点评:34

【VSCode】格式化缩进代码,vscode格式化缩进


1)文件 —> 首选项

因为 VsCode 默认启用了根据文件类型自动设置tabsize的选项,在设置中添加:

"editor.detectIndentation": false


2)编辑器配置

在项目文件中新建 .editorconfig 文件
为特定类型文件指定缩进大小、缩进类型(空格,或tab),是否自动插入末行等等。

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

相关文章

    暂无相关文章

用户点评