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

前端 未结 14 1829
刺人心
刺人心 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: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.

提交回复
热议问题