Put in the .vimrc file taken from :h :DiffOrig
following:
command DiffOrig vert new | set bt=nofile | r
Then, when prompted, press o for ok, and then do :DiffOrig . You will be presented with diff.
If you decide that you want to take the file from disk, do :e! to reload the file from disk.
Quick Review :DiffOrig
Separate the new buffer vertically and read from the disk in the corresponding file and mark both buffers that need to be distinguished.
Glory details for :DiffOrig
:vert {cmd} will execute any {cmd}, and any splits will be split vertically.new open a new section with a new bufferset bt=nofile set 'buftype' to nofile , so the file will not be written to diskr not suitable for :read {file} . r # reads into the buffer an alternate file, which is the buffer just split. This alternate file is the file in question, read from disk.0d_ , which is short for 0delete _ . When an alternate file is read, it leaves an empty line at the top. 0delete _ will delete the top line in the black hole register so that it does not mess with other registers.diffthis set the buffer to distinguish.windcmd p switches back to the previous window. This is the same as <cw>p in normal mode.diffthis this sets up a modified buffer for inclusion in the diff set.
For more information:
:h :DiffOrig :h :e :h :diff :h vert :h new :hr :hd :h "_ :h windcmd :h diffthis :h :c_#
source share