我正在做一个项目,有些人使用 vi,有些人使用 emacs,还有一些人(包括 gedit)。强制(至少在视觉上)样式的最简单但通用的方法(虽然不完美)是将以下行添加到每个文件的末尾:
...
return 0;
}
// Editor modelines - generated by http://www.wireshark.org/tools/modelines.html
// Local variables:
// c-basic-offset: 4
// tab-width: 4
// indent-tabs-mode: t
// truncate-lines: 1
// End:
// vim:set ft=cpp ts=4 sw=4 sts=4 nowrap: cindent:
问题是:如何在“一行”代码中转换 emacs 部分(就像 vim 一样)?并将其保留在源文件的末尾(而不是顶部)。
(可能这可以改写为 Lisp 问题,但我不熟悉)
最佳答案
目录局部变量可能是更好的方法。
- http://www.emacswiki.org/emacs/DirectoryVariables
- http://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
单个.dir-locals.el
文件将被所有人处理,根本不需要文件局部变量。
vim 很可能有类似的机制?
关于一行文件末尾的 Emacs 模式行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5382475/