14. buffer 级配置:EditorConfig 与 file-local

这两类配置只影响单个 buffer,优先于全局选项。

EditorConfig

打开文件时从所在目录向上找 .editorconfig(root = true 处停止向上; 靠近文件的 section 覆盖上面的)。支持的标准属性:

属性效果
indent_stylespace / tab
indent_size缩进宽度(tab = 用 tab_width)
tab_widthTab 显示宽度
end_of_linelf / crlf
trim_trailing_whitespace存盘时删行尾空白
insert_final_newline存盘时保证文末换行
max_line_length行宽上限

file-local variables

只认白名单,绝不 eval 文件里的代码。两种写法:

c
/* -*- 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 产品页