自打开缓冲区后,如何撤消所有更改?我想可能有某种形式:earlier可以做到这一点.
更新:许多人建议遍历早期文件写入的解决方案.这不是我要求的.我想恢复原始状态,当我最初将文件加载到缓冲区时,无论从那时起写了多少次.
ib.*_*ib. 74
要将当前缓冲区恢复到撤消列表中Vim记住的第一个更改之前的状态(请参阅参考资料:help undo-tree),请使用命令
:u1|u
Run Code Online (Sandbox Code Playgroud)
Zso*_*kai 51
你可以使用
:edit!
Run Code Online (Sandbox Code Playgroud)
命令进入最早保存状态.有关:help edit!更多信息,请参阅
您还可以检查类似gundo.vim(可在此处找到)的内容,以图形方式显示整个撤消树,并且您可以轻松地在点之间跳转.然后有histwin plugin我尚未使用的,但提供类似的功能.
从文档中
:u [ndo] {N}在更改号码{N}后跳转到.参见| undo-branches | 对于{N}的含义.{Vi无此功能}
如果你输入
:u 1
它似乎是在第一次改变后去的; 按下u或键入:u将返回到更改.
否则,您可以使用非常大的计数:earlier或g-
例如
:earlier 100000000或100000000g-
如果你将它放入映射/命令中,它可以做任何这些而不会有太多麻烦.例如
:nnoremap <C-F12> :earlier 100000000<CR>
要访问以前保存的文件状态,我认为需要执行以下操作:
:earlier 1f
从文档中:
:earlier {N}f Go to older text state {N} file writes before.
When changes were made since the last write
":earlier 1f" will revert the text to the state when
it was written. Otherwise it will go to the write
before that.
When at the state of the first file write, or when
the file was not written, ":earlier 1f" will go to
before the first change.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25362 次 |
| 最近记录: |