Changing the scope of 'diff' to something more granular?

21 views
Skip to first unread message

Tim Chase

unread,
Apr 24, 2020, 5:10:09 PM4/24/20
to v...@vim.org
I have a couple files that changed and can diff any pair of them with

$ vim old-a.txt new-a.txt

which works as expected. However, if I try to diff old-a/new-a and
also try to :diffsplit old-b/new-b, it compares *all* of those files.
Which is also expected. So currently I need to launch each diff in
its own session of vim.

shell1$ vim old-a.txt new-a.txt
...
shell2$ vim old-b.txt new-b.txt

While this is functional (and less bad within a tmux session), is it
possible to narrow the scope of a :vimdiff to a vim-tab so that I can
have a single vim session with multiple file-diff pairs within?

Mostly it's nice to have things like `gd`, `gD`, jump to places that
show the diffs in the destination as well.

Thanks for any ideas,

-tim



Paul

unread,
Apr 25, 2020, 10:08:22 AM4/25/20
to vim...@googlegroups.com
On Fri, Apr 24, 2020 at 04:09:48PM -0500, Tim Chase wrote:
>While this is functional (and less bad within a tmux session), is it
>possible to narrow the scope of a :vimdiff to a vim-tab so that I can
>have a single vim session with multiple file-diff pairs within?

Unless I'm misunderstanding, why don't you open the new diff pair in a new tab?
signature.asc

Tim Chase

unread,
Apr 25, 2020, 10:41:44 AM4/25/20
to Paul, vim...@googlegroups.com
Well dang. That does work. I misread/misunderstood the text at

:help 'diff'

which says that the setting is "local to window". In my
(mis-conceived) tests, opening a new vim window (:sp) from a diff'ed
window resulted in a windo that had 'diff' set, leading me to
(mis-)understand "window" as a vim-session not a vim-window. Had I
properly tested, I would have noticed that after a ":sp" on a diffed
window, I could then

:set nodiff

on one of those and it was in fact scoped to a vim-window not a
vim-session.

Reading up at ":help start-vimdiff" it does indeed say that "Diffs
are local to the current tab page" which is exactly what I wanted
and just failed to find/understand.

Thanks for setting me straight!

-tim




Reply all
Reply to author
Forward
0 new messages