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

后端 未结 7 753
执念已碎
执念已碎 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:15

    From the documentation

    :u[ndo] {N} Jump to after change number {N}. See |undo-branches| for the meaning of {N}. {not in Vi}

    If you type :u 1 it appears to go to after the first change; pressing u or typing :u will then go back to the change.

    Otherwise, you can use a very large count to :earlier or g- e.g. :earlier 100000000 or 100000000g-

    If you put this into a mapping/command, it could do any of these without too much trouble. e.g.

    :nnoremap :earlier 100000000

提交回复
热议问题