How to undo all changes in a buffer made since it was open in Vim?

后端 未结 7 742
执念已碎
执念已碎 2021-01-30 08:38

How can I undo all changes since opening a buffer? I imagine there may be some form of :earlier that does this.

Update: Many are suggesting

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-30 09:02

    To access previously saved file status, I think the following work :

    :earlier 1f

    From the documentation :

     :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.
    

提交回复
热议问题