Can I see changes before I save my file in Vim?

前端 未结 14 1770
刺人心
刺人心 2020-12-07 07:33

I use Vim. I open a file. I edit it and I want to see what I\'ve edited before I save it.

How can I do this in Vim?

14条回答
  •  既然无缘
    2020-12-07 07:48

    You can make vim create a last backup and original backup with:

    :set backup
    :set patchmode=.orig 
    

    Thereafter, you can open them in a split:

    :vsp %:p~ or :vsp %:.orig
    

    And from there do:

    :vimdiff in each buffer
    

    If you're dead set on no leftovers but want vimdiff, you could also do:

    ggVGy    # copy the whole buffer
    :vnew    # open a split
    CTRL-W w # switch to it
    shift-P  # paste at start
    

    and then do :diffthis on each split

提交回复
热议问题