14. buffer 级配置:EditorConfig 与 file-local
这两类配置只影响单个 buffer,优先于全局选项。
EditorConfig
打开文件时从所在目录向上找 .editorconfig(root = true 处停止向上; 靠近文件的 section 覆盖上面的)。支持的标准属性:
| 属性 | 效果 |
|---|---|
indent_style | space / tab |
indent_size | 缩进宽度(tab = 用 tab_width) |
tab_width | Tab 显示宽度 |
end_of_line | lf / crlf |
trim_trailing_whitespace | 存盘时删行尾空白 |
insert_final_newline | 存盘时保证文末换行 |
max_line_length | 行宽上限 |
file-local variables
只认白名单,绝不 eval 文件里的代码。两种写法:
/* -*- mode: c; indent-offset: 2; tab-width: 4 -*- */
或文件尾:
Local Variables:
fill-column: 80
End:
白名单:`mode`(只能切到已登记的主模式)、`comment-start`、`comment-end`、
`fill-column`、`indent-offset`、`tab-width`、`indent-style`、`insert-spaces?`、
`eol`、`trim-trailing?`、`final-newline?`、`truncate-lines`、`eval-minibuffer?`。原始 Markdown:coxn 使用手册(Markdown) · 安装包:coxn 产品页