gpt4 book ai didi

Emacs 缩进/取消缩进当前行

转载 作者:行者123 更新时间:2023-12-04 00:46:19 29 4
gpt4 key购买 nike

我使用 Emacs 有一段时间了,我真的很想念一个古老的 Geany 快捷方式 - “C-i”和“C-u”。

“C-i”缩进整个当前行(将鼠标光标保持在原处),“C-u”取消整个当前行的缩进。

我发现了很多 Emacs 的缩进命令,有些是为了缩进一个区域。基本上,我需要的是 Vim 的“>>”和“<<”,但要将鼠标光标保持在原处。

但是,我的主要疑问是如何只缩进当前行。

有什么想法吗?提前致谢!

编辑Tab加两个空格,我想在行的任意位置在行首加两个空格,或者去掉行首两个空格。

最佳答案

这是我在 emacs 中 TAB 键的默认行为,它运行命令 indent-for-tab-command。来自 documentation pages 之一:

In programming modes, adds or removes some combination of space and tab characters at the start of the line, in a way that makes sense given the text in the preceding lines. If the region is active and spans multiple lines, all those lines are indented this way. If point was initially within the current line's indentation, it is positioned after that indentation; otherwise, it remains at same point in the newly-indented text. See Program Indent.

还值得注意的是 tab-always-indent 变量:

The variable tab-always-indent tweaks the behavior of the (indent-for-tab-command) command. The default value, t, gives the behavior described above. If you change the value to the symbol complete, then first tries to indent the current line, and if the line was already indented, it tries to complete the text at point (see Symbol Completion). If the value is nil, then indents the current line only if point is at the left margin or in the line's indentation; otherwise, it inserts a real tab character.

关于Emacs 缩进/取消缩进当前行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9706684/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com