EditorConfig的使用

EditorConfig帮助开发者在不同IDE中保持一致的代码风格。通过.editorconfig配置文件,可以指定文件的编码、换行符样式、缩进等属性,确保跨平台、跨编辑器的代码一致性。

参考链接

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值