您如何“重做”? “撤消”后发生的变化用 Emacs 吗?

发布于 2024-09-15 04:06:25 字数 180 浏览 3 评论 0原文

这篇文章说“Emacs 具有重做功能,因为您可以撤消时反转方向,从而撤消撤消”。

这意味着什么?用户如何使用 Emacs 进行“重做”?

This article says that "Emacs has redo because you can reverse direction while undoing, thereby undoing the undo".

What does this mean? How can a user 'redo' with Emacs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(11

雨落□心尘 2024-09-22 04:06:26

如果要重做上次操作,请执行以下操作。

  1. ESC
  2. 执行另一次撤消操作 (C + /)

If you want to redo the last operation, do the following.

  1. ESC
  2. Do another undo (C + /)
來不及說愛妳 2024-09-22 04:06:26

在厄运 emacs 中,

Ctrl + Shift + - 撤消

Alt + Shift + - 重做

In doom emacs,

Ctrl + Shift + - to undo

Alt + Shift + - to redo

落花浅忆 2024-09-22 04:06:25

简短版本:通过撤消撤消。如果您撤消,然后执行非编辑命令,例如 Cf,则下一个撤消将撤消该撤消,从而导致重做。

更长的版本:

您可以将撤消视为对操作堆栈进行操作。如果您在一系列撤消操作后执行某些命令(甚至是导航命令,例如 Cf),则所有撤消都会被推送到操作堆栈。因此,下一个撤消操作将撤消上一个命令。假设您确实有一个如下所示的操作序列:

  1. 插入“foo”
  2. 插入“bar”
  3. 插入“我喜欢垃圾邮件”

现在,您可以撤消。它撤消最后一个操作,产生以下列表:

  1. Insert "foo"
  2. Insert "bar"

如果此时执行撤消以外的其他操作 - 例如 Cf,操作堆栈如下所示:

  1. Insert “foo”
  2. 插入“bar”
  3. 插入“我爱垃圾邮​​件”
  4. 撤消插入“我爱垃圾邮​​件”

现在,当您撤消时,首先撤消的就是撤消。产生原始堆栈(和文档状态):

  1. 插入“foo”
  2. 插入“bar”
  3. 插入“I love spam”

如果您执行修改命令来破坏撤消序列,则该命令将在撤消之后添加,因此是第一件事之后将被撤销。假设您在“bar”上退格而不是按 Cf。然后你就会

  1. 插入“foo”
  2. 插入“bar”
  3. 插入“我喜欢垃圾邮件”
  4. 撤消插入“我喜欢垃圾邮件”
  5. 删除“bar”

这种添加/重新添加会无限地发生。这需要一些时间来适应,但它确实为 Emacs 提供了高度灵活且强大的撤消/重做机制。

Short version: by undoing the undo. If you undo, and then do a non-editing command such as C-f, then the next undo will undo the undo, resulting in a redo.

Longer version:

You can think of undo as operating on a stack of operations. If you perform some command (even a navigation command such as C-f) after a sequence of undo operations, all the undos are pushed on to the operation stack. So the next undo undoes the last command. Suppose you do have an operation sequence that looks like this:

  1. Insert "foo"
  2. Insert "bar"
  3. Insert "I love spam"

Now, you undo. It undoes the last action, resulting in the following list:

  1. Insert "foo"
  2. Insert "bar"

If you do something other than undo at this point - say, C-f, the operation stack looks like this:

  1. Insert "foo"
  2. Insert "bar"
  3. Insert "I love spam"
  4. Undo insert "I love spam"

Now, when you undo, the first thing that is undone is the undo. Resulting in your original stack (and document state):

  1. Insert "foo"
  2. Insert "bar"
  3. Insert "I love spam"

If you do a modifying command to break the undo sequence, that command is added after the undo and is thus the first thing to be undone afterwards. Suppose you backspaced over "bar" instead of hitting C-f. Then you would have had

  1. Insert "foo"
  2. Insert "bar"
  3. Insert "I love spam"
  4. Undo insert "I love spam"
  5. Delete "bar"

This adding/re-adding happens ad infinitum. It takes a little getting used to, but it really does give Emacs a highly flexible and powerful undo/redo mechanism.

生生漫 2024-09-22 04:06:25

撤消: C-_

撤消后重做: Cg C-_

C-_ 重做 C-_ 撤消的操作
要多次重做 emacs 命令,请执行命令,然后键入 Cxz,然后在 z 键上多次键入以重复该命令(有趣)当你想多次执行一个宏时)

To undo: C-_

To redo after a undo: C-g C-_

Type multiple times on C-_ to redo what have been undone by C-_
To redo an emacs command multiple times, execute your command then type C-xz and then type many times on z key to repeat the command (interesting when you want to execute multiple times a macro)

夜司空 2024-09-22 04:06:25
  • 撤消一次:C-/
  • 撤消两次:C-/ C-/
  • 重做一次,撤消后立即:Cg C-/
  • 要重做两次,撤消后立即:Cg C-/ C-/。请注意,Cg 不重复。
  • 要立即撤消,再次,一次:Cg C-/
  • 要再次立即撤消,两次:Cg C-/ C-/
  • 再次重做,同样...

如果您按下了任何键(无论是键入字符还是只是移动光标)自上次撤消命令以来,无需在下一次撤消/重做之前键入 CgCg 只是一个安全的按键,它本身没有任何作用,但可以作为非撤消键来表示撤消序列的结束。按另一个命令,例如 Cf 也可以;只是它会将光标从您所在的位置移动。

如果您无意中按了 Cg 或其他命令,并且现在正在以错误的方向撤消操作,只需按 Cg 即可再次反转方向。在达到您想要的撤消之前,您必须一路撤消意外的重做和撤消,但如果您继续按 C-/,您最终将达到您想要的状态。事实上,如果您按一下 Cg 一次,然后按 C-/ 足够多次,缓冲区曾经处于的每个状态都是可以访问的。

除了 C-/ 之外,撤消 的替代快捷键还有 C-_Cx u>Mx 撤消

有关 Emacs 撤消系统的更多详细信息,请参阅 Emacs 手册中的撤消

  • To undo once: C-/
  • To undo twice: C-/ C-/
  • To redo once, immediately after undoing: C-g C-/
  • To redo twice, immediately after undoing: C-g C-/ C-/. Note that C-g is not repeated.
  • To undo immediately again, once: C-g C-/
  • To undo immediately again, twice: C-g C-/ C-/
  • To redo again, the same…

If you have pressed any keys (whether typing characters or just moving the cursor) since your last undo command, there is no need to type C-g before your next undo/redo. C-g is just a safe key to hit that does nothing on its own, but counts as a non-undo key to signal the end of your undo sequence. Pressing another command such as C-f would work too; it’s just that it would move the cursor from where you had it.

If you hit C-g or another command when you didn’t mean to, and you are now undoing in the wrong direction, simply hit C-g to reverse your direction again. You will have to undo all the way through your accidental redos and undos before you get to the undos you want, but if you just keep hitting C-/, you will eventually reach the state you want. In fact, every state the buffer has ever been in is reachable, if you hit C-g once and then press C-/ enough times.

Alternative shortcuts for undo, other than C-/, are C-_, C-x u, and M-x undo.

See Undo in the Emacs Manual for more details on Emacs’s undo system.

探春 2024-09-22 04:06:25

对于那些想要拥有更常见的撤消/重做功能的人,有人编写了 <代码>undo-tree.el。它提供非 Emacs 撤消的外观和感觉,但提供对撤消历史记录的整个“树”的访问。

我喜欢 Emacs 的内置撤消系统,但发现这个包非常直观。

以下是文件本身的评论:

Emacs 拥有强大的撤消系统。
与标准撤消/重做系统不同
在大多数软件中,它允许您
恢复缓冲区的任何过去状态
(而标准撤消/重做系统
一旦你可以失去过去的状态
重做)。然而,这种力量是在一个
价格:很多人发现Emacs的undo
系统混乱且难以使用,
产生许多包
将其替换为功能较弱但
更直观的撤消/重做系统。

数据丢失均符合标准
撤消/重做,以及 Emacs 的混乱
撤消,源于尝试处理撤消
历史作为一个线性序列
变化。它不是。这
此提供的“undo-tree-mode”
软件包取代了 Emacs 的撤消系统
使用处理撤消历史的系统
就其本质而言:一棵分枝树
变化。这个简单的想法允许
更直观的行为
标准撤消/重做系统
与从未有过的力量相结合
失去任何历史记录。增加的一面
好处是撤消历史记录可以在某些情况下
更有效地存储案例,
允许更多的变化积累
在 Emacs 开始丢弃之前
历史。

For those wanting to have the more common undo/redo functionality, someone has written undo-tree.el. It provides the look and feel of non-Emacs undo, but provides access to the entire 'tree' of undo history.

I like Emacs' built-in undo system, but find this package to be very intuitive.

Here's the commentary from the file itself:

Emacs has a powerful undo system.
Unlike the standard undo/redo system
in most software, it allows you to
recover any past state of a buffer
(whereas the standard undo/redo system
can lose past states as soon as you
redo). However, this power comes at a
price: many people find Emacs' undo
system confusing and difficult to use,
spawning a number of packages that
replace it with the less powerful but
more intuitive undo/redo system.

Both the loss of data with standard
undo/redo, and the confusion of Emacs'
undo, stem from trying to treat undo
history as a linear sequence of
changes. It's not. The
`undo-tree-mode' provided by this
package replaces Emacs' undo system
with a system that treats undo history
as what it is: a branching tree of
changes. This simple idea allows the
more intuitive behaviour of the
standard undo/redo system to be
combined with the power of never
losing any history. An added side
bonus is that undo history can in some
cases be stored more efficiently,
allowing more changes to accumulate
before Emacs starts discarding
history.

清引 2024-09-22 04:06:25

请注意撤消树重做的怪癖!

许多流行的“入门工具包”(prelude、purcell、spacemacs)都与撤消树捆绑在一起。大多数(全部?)甚至自动启用它。如前所述,撤消树是可视化和遍历撤消/重做树的便捷方法。 Prelude 甚至给它一个调和弦 (uu),还有 Cx u

问题是:undo-tree 似乎破坏了 Emacs 的默认且众所周知的重做绑定:Cg C-/

相反,您可以使用这些对称键进行撤消/重做

C-/     undo
C-S-/   redo

这些键很有用,因为有时您希望在不打开可视化工具的情况下快速重做

Beware of an undo-tree quirk for redo!

Many popular “starter kits” (prelude, purcell, spacemacs) come bundled with undo-tree. Most (all?) even auto-enable it. As mentioned, undo-tree is a handy way to visualize and traverse the undo/redo tree. Prelude even gives it a key-chord (uu), and also C-x u.

The problem is: undo-tree seems to wreck Emacs’ default and well-known binding for redo: C-g C-/.

Instead, you can use these symmetrical keys for undo/redo:

C-/     undo
C-S-/   redo

These are useful since sometimes you want to quickly redo without opening up the visualizer.

别闹i 2024-09-22 04:06:25

Emacs 28 添加了一个 redo 命令(称为 <代码>撤消重做)。

如果您想要更典型的撤消/重做,可以使用以下命令。

(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "C-S-z") 'undo-redo)

要访问此功能(也可以使用非线性历史记录,请参阅 undo-fu 这是 emacs 上内置 undo 的薄包装器)。

Emacs 28 adds a redo command (called undo-redo).

If you want to have more typical undo/redo, the following commands can be used.

(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "C-S-z") 'undo-redo)

To access this functionality (with the ability to use non-linear history too, see undo-fu which is a thin wrapper on emacs built in undo).

会傲 2024-09-22 04:06:25

我发现 redo.el 对于“正常”操作非常方便撤消/重做,我通常将其绑定到 CSz 并将撤消绑定到 Cz,如下所示:

(when (require 'redo nil 'noerror)
    (global-set-key (kbd "C-S-z") 'redo))

(global-set-key (kbd "C-z") 'undo)

只需下载文件,将其放入您的 lisp 路径中并将以上内容粘贴到您的 .emacs 中。

I find redo.el extremly handy for doing "normal" undo/redo, and I usually bind it to C-S-z and undo to C-z, like this:

(when (require 'redo nil 'noerror)
    (global-set-key (kbd "C-S-z") 'redo))

(global-set-key (kbd "C-z") 'undo)

Just download the file, put it in your lisp-path and paste the above in your .emacs.

空城之時有危險 2024-09-22 04:06:25

默认情况下,Emacs 中的重做需要按 Cg,然后撤消。

然而,也可以使用 Emacs 内置的 undo 来实现重做命令。

undo-fu,使用Emacs内置的撤消功能来公开撤消和重做。


编辑,撤消功能现在已集成到邪恶模式中(如果您是邪恶模式用户)。

例子:

(use-package undo-fu)
(use-package evil
  :init
  (setq evil-undo-system 'undo-fu))

By default, redo in Emacs requires pressing C-g, then undo.

However it's possible use Emacs built-in undo to implement a redo command too.

The package undo-fu, uses Emacs built-in undo functionality to expose both undo and redo.


Edit, undo-fu has now been integrated into evil-mode (if you're an evil-mode user).

Example:

(use-package undo-fu)
(use-package evil
  :init
  (setq evil-undo-system 'undo-fu))
清旖 2024-09-22 04:06:25

Doom Emacs 用户,我希望您已经滚动到这里或在页面上搜索“doom”...

  • Doom Emacs 打破了普通 Emacs 重做快捷方式:
    Cg C-/ C-/ C-/ 等(或 Cg <代码>C-_ C-_ C-_ 等)
    ...相反,只是不断地破坏
  • Doom Emacs 破坏了其他答案之一中提到的撤消树重做快捷方式,该快捷方式对于 spacemacs 等很有用:
    SC-/(又名C-?
    ...相反,这会引发错误“C-?未定义”。

你需要的是:

  • 处于邪恶模式(Cz 切换进入和退出邪恶模式)(在邪恶模式下应该看到蓝色光标,而不是橙色光标)并且
  • 处于“命令”状态mode' 又称“正常模式”(与“插入模式”相对)(Esc 切换到命令模式)(应该看到块光标,而不是行光标),然后是
  • u 表示撤消
  • Cr 表示重做

Doom Emacs users, I hope you've scrolled this far or searched for 'doom' on the page...

  • Doom Emacs breaks the vanilla Emacs redo shortcut:
    C-g C-/ C-/ C-/ etc (or C-g C-_ C-_ C-_ etc)
    ...and instead that just keeps undoing.
  • Doom Emacs also breaks the undo-tree redo shortcut mentioned in one of the other answers as being useful for spacemacs etc:
    S-C-/ (AKA C-?)
    ...and instead that throws the error "C-? is not defined".

What you need is:

  • to be in evil-mode (C-z to toggle in and out of evil-mode) (in evil-mode should see blue cursor, not orange cursor) and
  • to be in 'command mode' AKA 'normal mode' (as opposed to 'insert mode') (Esc to switch to command mode) (should see block cursor, not line cursor), and then it's
  • u for undo and
  • C-r for redo
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文