0

I want to review changes I made to my file before I save it. Is it possible to do this, preferably without using vimrc or installing additional software? I'm using Neovim on Windows.

I tried one of the answers here:

https://stackoverflow.com/questions/749297/can-i-see-changes-before-i-save-my-file-in-vim

Which was:

:w !diff % -

This is what I get:

'diff' is not recognized as an internal or external command,
operable program or batch file.

shell returned 1

I also tried putting the command through bash using Windows Subsystem for Linux:

:w !bash -c 'diff % -'

The result:

diff: -: Illegal seek

shell returned 2

I tried both Windows Command Line and Windows PowerShell and both of the above give the same results. I see there are other answers that include editing vimrc or installing other software, but I wanted to see if there was a simple way to do it first.

1 Answer 1

0

I haven't figured out the reason for the error, but I did find a simple workaround:

:w !bash -c "cat - | diff % -"

Looks like diff is trying to do a seek that isn't supported by the stream. So buffering it through cat seems to solve the problem.

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Jul 3 at 5:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .