主题
EditorConfig
1. 新建 .editorconfig
ini
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[Makefile]
indent_style = tab配置说明
root = true:当前文件作为根配置,向上不再继续查找charset = utf-8:统一文件编码indent_style = space:统一使用空格缩进indent_size = 2:统一 2 空格缩进end_of_line = lf:统一换行符为LFinsert_final_newline = true:文件末尾保留换行trim_trailing_whitespace = true:移除行尾空格[*.md]单独关闭行尾空格清理,避免误伤 Markdown 强制换行[Makefile]使用tab,避免命令缩进失效
3. 验证
新建任意文件,手动输入 4 空格缩进、CRLF 换行、文件末尾不留空行;保存后如果编辑器自动纠正,说明已经生效。
注意事项
编辑器要求
大多数编辑器原生支持 EditorConfig。如果本地编辑器没有生效,先确认是否安装了 EditorConfig 插件。
