Emacs c++ 选项卡写入空格删除
Emacs c++ tabs writing spaces removing
我看到很多关于 emacs 和 tabs/spaces 主题的问题,但没有人谈论这个:
我有 C++ 模式的 emacs 和制表符作为缩进字符,如果我按回车键换行 emacs 自动缩进带制表符但如果我尝试删除它 "tab" 我只删除一个 space.
我知道 emacs 使用 spaces 创建选项卡但是如果我想删除那个 "tab" 我想直接删除 4(或 8)spaces 而不是一个其中之一,在 python 模式下按预期工作,但在 C++ 模式下没有。有一个变量或任何解决方法?
您的退格键 (<DEL>
) 可能绑定到命令 backward-delete-char-untabify
。将它绑定到其他东西,例如delete-backward-char
.
来自 Elisp 手册,节点 Program Modes:
In most programming languages, indentation should vary from line to
line to illustrate the structure of the program. Therefore, in most
programming language modes, typing <TAB>
updates the indentation of the
current line.
Furthermore, <DEL>
is usually
bound to backward-delete-char-untabify
, which deletes backward
treating each tab as if it were the equivalent number of spaces, so that
you can delete one column of indentation without worrying whether the
whitespace consists of spaces or tabs.
IOW,您不喜欢的行为在您使用的编程模式中默认提供。
实际上,如果您在 c++-mode
,<DEL>
将绑定到命令 c-electric-backspace
。该函数 (C-h f c-electric-backspace
) 的文档告诉您:
c-electric-backspace
is an interactive compiled Lisp function in
cc-cmds.el
.
(c-electric-backspace ARG)
Delete the preceding character or whitespace.
If c-hungry-delete-key
is non-nil
(indicated by "/h"
on the mode
line) then all preceding whitespace is consumed. If however a prefix
argument is supplied, or c-hungry-delete-key
is nil
, or point is
inside a literal then the function in the variable
c-backspace-function
is called.
默认情况下,用户选项 c-backspace-function
(C-h v
) 的值似乎是... backward-delete-char-untabify
。因此,您可以自定义该选项以将其设置为其他功能,例如 delete-backward-char
。这只会改变 C++ 和 C 模式的行为。
我看到很多关于 emacs 和 tabs/spaces 主题的问题,但没有人谈论这个:
我有 C++ 模式的 emacs 和制表符作为缩进字符,如果我按回车键换行 emacs 自动缩进带制表符但如果我尝试删除它 "tab" 我只删除一个 space.
我知道 emacs 使用 spaces 创建选项卡但是如果我想删除那个 "tab" 我想直接删除 4(或 8)spaces 而不是一个其中之一,在 python 模式下按预期工作,但在 C++ 模式下没有。有一个变量或任何解决方法?
您的退格键 (<DEL>
) 可能绑定到命令 backward-delete-char-untabify
。将它绑定到其他东西,例如delete-backward-char
.
来自 Elisp 手册,节点 Program Modes:
In most programming languages, indentation should vary from line to line to illustrate the structure of the program. Therefore, in most programming language modes, typing
<TAB>
updates the indentation of the current line.Furthermore,
<DEL>
is usually bound tobackward-delete-char-untabify
, which deletes backward treating each tab as if it were the equivalent number of spaces, so that you can delete one column of indentation without worrying whether the whitespace consists of spaces or tabs.
IOW,您不喜欢的行为在您使用的编程模式中默认提供。
实际上,如果您在 c++-mode
,<DEL>
将绑定到命令 c-electric-backspace
。该函数 (C-h f c-electric-backspace
) 的文档告诉您:
c-electric-backspace
is an interactive compiled Lisp function incc-cmds.el
.
(c-electric-backspace ARG)
Delete the preceding character or whitespace.
If
c-hungry-delete-key
is non-nil
(indicated by"/h"
on the mode line) then all preceding whitespace is consumed. If however a prefix argument is supplied, orc-hungry-delete-key
isnil
, or point is inside a literal then the function in the variablec-backspace-function
is called.
默认情况下,用户选项 c-backspace-function
(C-h v
) 的值似乎是... backward-delete-char-untabify
。因此,您可以自定义该选项以将其设置为其他功能,例如 delete-backward-char
。这只会改变 C++ 和 C 模式的行为。