Re: [vim/vim] Diff mode gets stuck (#336)

231 views
Skip to first unread message

Max Waterman

unread,
Oct 24, 2017, 11:23:58 PM10/24/17
to vim/vim, Subscribed

I'm seeing this problem too, and find that the recommended ':bufdo diffoff' does not work.
As I am seeing it, it is like this:

  1. open vim on a file
  2. ctrl-wv top open another vertical buffer
  3. :Ex and navigate to another file (with similar contents)
  4. run ':diffthis' on both buffers
  5. do some stuff, write both buffers, and now move onto another couple of files...by...
  6. :Ex in each 'window' and :Ex to get different files
  7. run ':diffthis' on both buffers

At this point, buffers seem to have almost all lines highlighted as having differences, even then they are identical. Doing a ':diffoff' on one of them, shows the other still has all lines 'different' to something.

This is where I conclude it is diffing with one of the buffers that is longer visible, so I am wondering how to turn diff off on everything, so I can 'start again', so to speak.

My searches suggest ':bufdo diffoff' would work, but no; similarly for 'bufdo diffoff!'.

If I 'think ahead', and run ':diffoff' on the buffers before I switch to new files, then all works as expected, but I am still open to forgetting to do that, at which point I am wishing there was a way to turn diff off completely, even on non-visible buffers.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Christian Brabandt

unread,
Oct 25, 2017, 2:56:21 AM10/25/17
to vim/vim, Subscribed

:bufdo diffoff should have worked, while :diffoff! only disables diff mode in buffers still visible in any windows. However I cannot imagine, why :bufdo :diffoff did not work. Perhaps those buffers weren't listed anymore? I think then the :bufdo command would skip those buffers. Perhaps the :diffoff! command should turn off diff mode for all buffers that exist, regardless of whether they are shown in a window.

Max Waterman

unread,
Oct 25, 2017, 3:02:49 AM10/25/17
to vim/vim, Subscribed

Hrm, is it :bufdo :diffoff, with an extra colon? I'll have to try when I'm next in my computer.

Marius Gedminas

unread,
Oct 25, 2017, 5:01:00 AM10/25/17
to vim/vim, Subscribed

Oh hey, it's my old bug! I once spent hours staring at vim's data structures with gdb, couldn't figure it out.

@davidmaxwaterman what's your Vim version? I personally haven't triggered this bug in a long time, and I don't think it's just because I'm now always careful to :diffoff before I switch buffers in a window.

(:bufdo :diffoff should be exactly the same as :bufdo diffoff -- vim allows extra : in front of ex command names.)

Max Waterman

unread,
Oct 25, 2017, 5:11:24 AM10/25/17
to vim/vim, Subscribed

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Mar 17 2017 12:13:35)

seems 'quite' recent - it's straight from ubuntu's repos:

05:09:27 ~$ dpkg -l | grep vim
ii  vim                                             2:8.0.0095-1ubuntu3                                      amd64        Vi IMproved - enhanced vi editor
ii  vim-common                                      2:8.0.0095-1ubuntu3                                      all          Vi IMproved - Common files
ii  vim-gnome                                       2:8.0.0095-1ubuntu3                                      all          Vi IMproved - enhanced vi editor (dummy package)
ii  vim-gtk3                                        2:8.0.0095-1ubuntu3                                      amd64        Vi IMproved - enhanced vi editor - with GTK3 GUI
ii  vim-gui-common                                  2:8.0.0095-1ubuntu3                                      all          Vi IMproved - Common GUI files
ii  vim-runtime                                     2:8.0.0095-1ubuntu3                                      all          Vi IMproved - Runtime files
ii  vim-tiny                                        2:8.0.0095-1ubuntu3                                      amd64        Vi IMproved - enhanced vi editor - compact version
05:09:32 ~$ 

Bram Moolenaar

unread,
Oct 26, 2017, 8:40:26 AM10/26/17
to vim/vim, Subscribed


Christian wrote:

> `:bufdo diffoff` should have worked, while `:diffoff!` only disables

> diff mode in buffers still visible in any windows. However I cannot
> imagine, why `:bufdo :diffoff` did not work. Perhaps those buffers
> weren't listed anymore? I think then the `:bufdo` command would skip
> those buffers. Perhaps the `:diffoff!` command should turn off diff
> mode for all buffers that exist, regardless of whether they are shown
> in a window.

The 'diff' option is window-local, thus using :bufdo doesn't do the
right thing. You want to use ":diffoff!", that's the only way to remove
hidden buffers from diff mode.

Diff mode allows for diffing against hidden buffers. It's sometimes
useful, but it also creates this confusion.

--
[SIR LAUNCELOT runs back up the stairs, grabs a rope
of the wall and swings out over the heads of the CROWD in a
swashbuckling manner towards a large window. He stops just short
of the window and is left swing pathetically back and forth.]
LAUNCELOT: Excuse me ... could somebody give me a push ...
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
Oct 27, 2017, 2:43:44 AM10/27/17
to vim/vim, Subscribed

The 'diff' option is window-local, thus using :bufdo doesn't do the right thing. You want to use ":diffoff!", that's the only way to remove hidden buffers from diff mode. Diff mode allows for diffing against hidden buffers. It's sometimes useful, but it also creates this confusion.

Okay, so :diffoff! should fix it finally. Now I really wonder what happened, that this did not work. I just made a quick test with three buffers and could not reproduce that behaviour, playing around with hidden and buflisted options. @davidmaxwaterman can you give a reproducible example?

Max Waterman

unread,
Oct 27, 2017, 3:00:30 AM10/27/17
to vim/vim, Subscribed

diffoff! seems to fix it for me.

This is how I tested it:

cd
mkdir tmp
cd tmp
for i in $(seq 4); do echo $i > $i.txt; done # make some files to diff
vim
:Ex # select 1.txt
ctrl-Wv
ctrl-Wctrl-W
:Ex # select 2.txt
:diffthis
ctrl-Wctrl-W
:diffthis
# at this point it is showing diffs for my first pair of files
# now I want to switch to diffing [34].txt - this is where I will do ':diffoff!' from now on
:Ex # select 3.txt
ctrl-Wctrl-W
:Ex # select 4.txt
:diffthis # at this point, we can already see it is diffing this file with [12].txt
ctrl-Wctrl-W
:diffthis # now diffing [1234].txt?

To be honest, I should have thought of adding the '!'.

Christian Brabandt

unread,
Oct 27, 2017, 3:04:06 AM10/27/17
to vim/vim, Subscribed

Okay, I take that as being a confirmation, that the problem is actually resolved :)

Reply all
Reply to author
Forward
0 new messages