Vim 中如何使用撤销树? [英] How is the undo tree used in Vim?

查看:32
本文介绍了Vim 中如何使用撤销树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个回答说:

Vim 的撤销/重做系统是无与伦比的.输入、撤销、输入其他内容,你仍然可以返回你输入的第一件事,因为 Vim 使用撤销树而不是堆栈.在几乎所有其他程序中,在这种情况下,您键入的第一件事的历史记录都会丢失.

Vim's undo/redo system is unbeatable. Type something, undo, type something else, and you can still get back the first thing you typed because Vim uses an undo tree rather than a stack. In almost every other program, the history of the first thing you typed is lost in this circumstance.

这是我第一次听说.我怎样才能沿着树回溯?

This is the first I hear of this. How can I backtrack along the tree?

推荐答案

另见 :h undo-redo,其中列出了所有命令及其用法.

See also :h undo-redo, which lists all the commands and their usage.

遍历撤销树有两种方法.一是回到过去".g+g- 会按时间顺序或逆时间顺序遍历树中的所有节点(这可能有点混乱,因为它可以在undo分支之间任意跳转,但如果你做 g- 足够长的时间,你最终总会到达你需要去的地方).:earlier:later 使用像 7m1h 这样的时间描述符;再次,这可以在撤消分支之间任意跳转.

There are two ways to traverse the undo tree. One is to go "back in time". g+ and g- will traverse all of the nodes in the tree in chronological or reverse-chronological order (which can be a bit confusing, because it can jump arbitrarily between undo branches, but if you do g- long enough you'll always get where you need to go eventually). :earlier and :later take a time descriptor like 7m or 1h; again this can jump you arbitrarily between undo branches.

另一种方法是使用 :undo n 跳转到树中的特定节点,其中 n 是一个动作的编号.(所有的动作,即文本的添加、删除、替换,都会按照你的操作顺序编号.)你可以通过 :undolist 来查找撤销树的叶子上的动作数量.这将使您轻松地在分支之间跳转.然后您可以使用 uCtrl-R 上下移动该分支.

The other way is to jump to specific nodes in the tree using :undo n where n is a number of an action. (All actions, i.e. text additions, deletions, replacements, are numbered sequentially as you do them.) You can look up the number of the actions on the leaves of the undo tree via :undolist. This will let you jump between branches easily. You can then use u and Ctrl-R to move up and down that branch.

Vim 帮助中有一些很好的例子.弄清楚这是如何工作的最好方法是稍微玩一下.

There are some good examples in the Vim help. The best way to figure out how this works is to play with it a bit.

这篇关于Vim 中如何使用撤销树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆