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

前端 未结 14 1756
刺人心
刺人心 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 08:10

    Not exactly what you're looking for but SCMDiff.vim is really cool. One keypress, and it diff-highlights your current file with the head revision in a source control repo. It's meant to work with many SCMS. I use it with perforce.

    0 讨论(0)
  • 2020-12-07 08:12

    git supports the following command

    :w !git diff --no-index -- % -

    map it to a command by adding the following to your ~/.vimrc

    command GitDiff execute "w !git diff --no-index -- % -"

    Now executing :GitDiff becomes a handy little command to quickly show the diff before each save.

    0 讨论(0)
提交回复
热议问题