EditorConfig
文章目录
参考资料:
示例
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# Matches multiple files with brace expansion notation
# Set default charset
[*.{js,py}]
charset = utf-8
# 4 space indentation
[*.py]
indent_style = space
indent_size = 4
# 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[**]
indent_style=space
indent_size=2
# tab_width=2
end_of_line=lf
charset=utf-8
trim_trailing_whitespace=false
insert_final_newline=true
root=true应用范围
位于[]内的字符串指示其下方属性的应用范围。
该字符串由普通字符与下列通配符组成:
*:匹配任何字符串,除了路径分隔符(/)。**:匹配任何字符串?:匹配任何单个字符[name]:匹配任何单个字符name[!name]:匹配任何不是name的单个字符{s1,s2,s3}:匹配字符串s1、s2或s3{num1,num2}:匹配num1至num2之间的整数
属性
indent_style
缩进方式。候选值:
space:空格hard-tabs:制表符
indent_size
一个缩进级别的空格数。候选值:
- 整数:规定每级缩进的列数和soft-tabs的宽度(译注:空格数)
tab:使用属性tab_width的值
tab_width
一个缩进级别的列数。一般无需指定。候选值:
- 整数:用于指定替代tab的列数
end_of_line
换行符。候选值:
lf:Linux 换行符\ncr:macOS 换行符\rcrlf:windows 换行符\r\n
charset
编码格式。候选值:
latin1utf-8utf-8-bom(不建议使用)utf-16beutf-16le
trim_trailing_whitespace
除去行尾的任意空白字符。候选值:
true:启用false:停用
insert_final_newline
确保文件以一个空白行结尾(若必要则添加)。候选值:
true:启用false:停用
root
支持EditorConfig的IDE会安装目录从里往外的顺序搜索匹配.editorconfig文件。
属性root指示是否继续向上搜索匹配。候选值:
true:搜索匹配到本级目录为止false:继续向上级搜索匹配
注释
以#或;开头的整行是注释,IDE不解析。
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论