EditorConfig-定义跨编辑器(IDE)统一代码显示风格规范

EditorConfig是定义项目或者project在不同编辑器和IDE代码显示风格的一种规范,帮助开发者更便捷团队协作(如不同编辑器默认定义的编码不一致导致乱码)。

使用规范:

1、在project根目录或者需要统一代码显示风格的文件目录下创建 .editorconfig 文件,文件编码选择 UTF-8编码,并使用 CRLF或 LF行分隔符,

2、定义使用统一规范的范围、文件类型和具体风格配置值

注意事项:editorconfig插件使用就近优先原则处理不同深度级别的.editorconfig 文件规则集合

示例:

 1   # top-most EditorConfig file
 2   root = true
 3 
 4   # Unix-style newlines with a newline ending every file
 5   [*]
 6   end_of_line = lf
 7   insert_final_newline = true
 8 
 9   # Matches multiple files with brace expansion notation
10   # Set default charset
11   [*.{js,py}]
12   charset = utf-8
13 
14   # 4 space indentation
15   [*.py]
16   indent_style = space
17   indent_size = 4
18 
19   # Tab indentation (no size specified)
20   [Makefile]
21   indent_style = tab
22 
23   # Indentation override for all JS under lib directory
24   [lib/**.js]
25   indent_style = space
26   indent_size = 2
27 
28   # Matches the exact files either package.json or .travis.yml
29   [{package.json,.travis.yml}]
30   indent_style = space
31   indent_size = 2

官方文档:EditorConfig

posted @ 2020-05-26 23:00  时间777  阅读(145)  评论(1)    收藏  举报