即使更改 .emacs 后,Emacs 也会自动添加换行符

标签 emacs text-editor

我目前使用的是 Mac,并且正在尝试将 Emacs 设置为默认情况下不在文件末尾添加换行符,但几乎我搜索的所有内容都表示只添加 (setq require-final-newline nil)到主目录中的 .emacs 文件...这不起作用。接下来我应该注意什么来改变?

这就是 .emacs 文件现在的样子

(custom-set-variables
  ;; custom-set-variables was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 '(gud-gdb-command-name "gdb --annotate=1")
 '(large-file-warning-threshold nil)
 '(require-final-newline nil))
(custom-set-faces
  ;; custom-set-faces was added by Custom.
  ;; If you edit it by hand, you could mess it up, so be careful.
  ;; Your init file should contain only one such instance.
  ;; If there is more than one, they won't work right.
 )

最佳答案

你尝试过吗:

(setq mode-require-final-newline nil)

文件的主要模式可能正在使用此变量的值......

如何找出哪些模式使用此变量而不是您尝试过的变量并不是立即显而易见的,但想必该模式的作者知道得更好......

因此,您可能想要更改该文件的主要模式,这可以通过回答此 SQ 问题来完成:How to tell emacs to open .h file in C++ mode? (显然可以根据您的需要自定义答案)。

关于即使更改 .emacs 后,Emacs 也会自动添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13574564/

相关文章:

emacs - 设置 emacs shell

c# - 让 csharp-mode Emacs 语法突出显示工作

vim - notepad++ 有 vim 插件吗?

text-editor - 如何在 Notepad++ 中将分屏重置为默认值

html - Pluma(RIP Gedit)是否有一个插件来突出显示匹配的 HTML 标签?

html - Emacs——正确缩进嵌入在 html 文件中的 css 代码

url - 如何在 Emacs Lisp 中 "URL decode"字符串?

emacs - `with-temp-file' 与 `org-map-entries' 的行为

c# - 从头开始创建文本/代码编辑器