文章目录
editorConfig
- editorConfig是编辑器配置,可以帮助开发者在不同的编辑器和IDE之间定义和维护一致的代码风格。比如文件缩进、换行等格式。
- 一般在项目根目录创建一个名为 .editorconfig 的文件,该文件的内容定义该项目的编码规范.当用IDE打开一个文件时,editorConfig插件会在打开文件的目录和其每一级父节点查找.editorconfig文件, 编辑器读取配置文件并依此格式化代码,如果没有的话就用编辑器默认配置.
- editorConfig 例子
# http://editorconfig.org
root = true
# 对所有的文件生效
[*]
charset = utf-8
indent_style = space
indent_size = 4
tab_width =4
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline= true
max_line_length = 80[*.{
json,yml}]
indent_size = 2[*.md]
trim_trailing_whitespace = false
- editorConfig 配置说明
root 表示是最顶层的配置文件,发现设为true时,才会停止查找.editorconfig文件
charset 设置编码 一般设置为utf8
indent_style 缩进类型(tab是硬缩进,space为软缩进)
indent_size 缩进的数量,如果indent_style为tab,则此属性默认为tab_width
tab_width 用一个整数来设置tab缩进的列数。默认是indent_size
end_of_line 换行符格式,值为lf、cr和crlf
trim_trailing_whitespace 设为true表示会去除换行行首的任意空白字符。
insert_final_newline 是否在文件的最后插入一个空行
- editorConfig 支持的编辑器
PS:我个人是Java YYDS,在研究BigData,也在尝试不同的IDE做开发,年轻人,冲冲冲!