参考链接
http://editorconfig.org/
http://www.alloyteam.com/2014/12/editor-config/
EditorConfig是什么
帮助开发者在不同IDE中保持一致的代码风格。工程中有.editorconfig配置文件及使用的IDE默认支持EditorConfig或安装插件支持即可。(VSCode是安装插件支持)
.editorconfig文件例子
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
# 打开的文件会在文件当前目录查找.editorconfig文件,如果没有找到则会一直往上级找,直至找到.editorconfig文件的root配置为true为止
root = true
# Unix-style newlines with a newline ending every file
[*]
#set to lf, cr, or crlf
end_of_line = lf
#true时,确保文件末尾是新一行
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8
# 4 space indentation
[*.py]
#缩进风格,set to tab or space
indent_style = space
#缩进大小,定义多少个空格或tab为一个缩进级别
indent_size = 4
# 2 space indentation
[*.js]
indent_style = space
indent_size = 2
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = space
indent_size = 2
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2