emacs - 如何禁用 Emacs 自动向右移动命令?

标签 emacs formatting comments

我在 Windows 7 上使用最新版本的 Emacs。假设我在 .emacs 中键入以下代码:

;test|

| 表示光标位置。现在,如果我按 Enter,文本将向右移动,看起来像:

                                                      ;test

如何禁用此功能?

最佳答案

这是根据 Emacs Lisp style guide 完成的:

Comments that start with a single semicolon, ';', should all be aligned to the same column on the right of the source code. Such comments usually explain how the code on that line does its job. For example:

(setq base-version-list                 ; There was a base
      (assoc (substring fn 0 start-vn)  ; version to which
             file-version-assoc-list))  ; this looks like
                                        ; a subversion.

如果您使用两个或多个分号,您会看到其他行为:

Comments that start with two semicolons, ';;', should be aligned to the same level of indentation as the code. Such comments usually describe the purpose of the following lines or the state of the program at that point.

...

Comments that start with three semicolons, ';;;', should start at the left margin. We use them for comments which should be considered a “heading” by Outline minor mode.

...

Comments that start with four semicolons, ';;;;', should be aligned to the left margin and are used for headings of major sections of a program.

自动缩进由 electric-indent-mode 完成。如果你想完全禁用它,把像

(electric-indent-mode -1)

在你的初始化文件中。您也可以使用类似的东西针对特定模式禁用它

(electric-indent-local-mode -1)

在适当的初始化 Hook 中。

按照风格指南的建议简单地使用两个分号也应该可以防止这种行为,这将使您从其他代码的 electric-indent-mode 中受益。

关于emacs - 如何禁用 Emacs 自动向右移动命令?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29728816/

相关文章:

java - 如何在Java Formatter中转义减号?

CSS 文本布局/格式问题

eclipse - 如何在 Eclipse 中自动格式化代码?

.htaccess - "Toggle Comment"对于 Netbeans 7.x 中的 .htaccess 文件?

java - 使用 Checkstyle 检查评论/Javadoc 字数

emacs - 在 emacs 中将光标移动到屏幕中间

python - emacs 中的 gdb : python commands (py and pi)

emacs - 如何防止 helm-swoop 在点返回符号?

search - "1 of n"Emacs 搜索结果

comments - WebStorm 注释当前行后自动转到下一行