保持项目代码风格一致性 -- 使用.editorconfig的配置文件

官网介绍

.editorconfig文件是一个配置文件,用于定义编码风格相关的规则,以便在不同的编辑器和IDE之间保持代码风格一致性。

一个基本的 .editorconfig文件可能包含以下内容:

# http://editorconfig.org

# 表示该文件有效
root = true

# 匹配所有文件
[*]

# 设置字符编码
charset = utf-8

# 行尾换行符设置,可选 \n (Unix), \r\n (Windows), 或 \r (Mac)
end_of_line = lf

# 在文件结束处插入新行
insert_final_newline = true

# 删除一个文件结束处的空行
trim_trailing_whitespace = true

# 指定缩进方式,可选 space 或 tab
indent_style = space

# 指定缩进大小,例如 2 或 4
indent_size = 2

 

 这个配置文件设置了字符编码、行尾格式、是否在文件结束处插入新行、是否删除行尾空格以及缩进方式和大小。这些规则会被很多编辑器和IDE遵守,比如 Visual Studio Code、Sublime Text、Atom 等。 

猜你喜欢

转载自blog.csdn.net/m0_71071209/article/details/140591384