IDEA .editorconfig 代码风格设置

IDEA About 1,150 words

默认支持的编辑器

  • IDEA
  • Visual Studio
  • GithubGitlab

需安装插件的编辑器

  • VS Code
  • Eclipse
  • Sublime Text

配置案例

# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

[*.md]
max_line_length = 0
trim_trailing_whitespace = false 

配置语法

root = true

EditorConfig插件会在文件夹中查找.editorconfig文件,解析文件内容,找到root = true.editorconfig文件就会停止查找。

注释

使用#;表示注释

指定配置适用文件类型

使用[*]表示:适用所有文件。

使用[*.md]表示:适用md结尾的文件。

使用[*.{js,ts,vue}]表示:适用jstsvue结尾的文件。

常用配置

  • indent_style:缩进样式。
    • tab
    • space
  • indent_size:缩进长度
    • 正整数,比如:2
    • tab
  • tab_widthtab键长度
    • 正整数
  • end_of_line:行结束标识符
    • lfUnixmacOS\n
    • crlfWindows\r\n
    • crClassic Mac OS\r
  • charset:字符集
    • utf-8
    • latin1
  • trim_trailing_whitespace:删除行尾空白字符
    • true
    • false
  • insert_final_newline:文件末尾新起一行
    • true
    • false
  • max_line_length:行最大长度
    • 正整数
    • off

参考

https://github.com/editorconfig/editorconfig

https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties

https://www.jetbrains.com/help/idea/editorconfig.html

https://www.geeksforgeeks.org/what-is-editorconfig

Views: 509 · Posted: 2023-10-18

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh