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

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

使用规范:编辑器

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

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

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

示例:插件

 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

官方文档:EditorConfigcode

相关文章
相关标签/搜索