如何撤消最后写入vim?

前端之家收集整理的这篇文章主要介绍了如何撤消最后写入vim?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
让我以这种方式提出这个问题.我在 vim中打开一个新文件,(版本1)
#include<stdio.h>
main()
{
...blah
}

然后使用< Esc>:w< Enter>写文件.然后做出修改(版本2)

#include<stdio.h>
main()
{
...blah
... edit1
... edit2 //and large number of changes here and there in code
}

然后使用&Esc.>:w< Enter&gt ;.保存更改. 有没有办法直接撤消对版本1的更改(因为它是最后一个保存),即不经常按u来撤消

从Vim的帮助:
: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.

所以,如果您在第二次保存后没有进行更改,可以使用以下操作:

:earlier 1f

另一方面,如果您在第二次保存后未保存更改,则:

:earlier 2f

解决你的问题.

请参阅:help:之前,:help:undolist.

原文链接:https://www.f2er.com/bash/384078.html

猜你在找的Bash相关文章