让编码习惯穿越编辑器editorConfig

编辑器就是生产力,符合我的编程习惯和风格的编辑器能给开发带来轻松愉快的心情和生产力。前端开发中愈来愈多东西须要经过配置文件来进行配置,如今编辑器也使用了这一方法。前端

意义

存在的目的是项目代码在不一样的编辑器中可以有相同的视觉呈现,使用不一样的编辑器开发也可以保持一向的代码风格和编程习惯。编程

注释方法

注释符号"#",使用注释符号能够将一行注释json

优先级

配置文件的优先级高于编辑器的设置编辑器

indent_style

可选项tab和space,缩进样式ide

indent_size

当indent_style为space时,缩进对应的空格数量。值为整数spa

tab_width

当indent_style为tab时,缩进的宽度值code

end_of_line

设置换行符号,可选值 'lf' 'cr' 'crlf'ip

insert_final_newline

每一个文件结尾是否包含一个空行,jslint的规范在代码结尾须要有一个空行用来代表代码的结束。可选值 'true'或者 'false'utf-8

trim_trailing_whitespace

删除每一行结尾的空白字符,可选值 'true' 或者 'false'ci

示例

# EditorConfig is awesome: https://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

参考地址

editerconfig.org

相关文章
相关标签/搜索