Vimdiff with multiple buffers

2,963 views
Skip to first unread message

Ven Tadipatri

unread,
Jan 21, 2016, 2:36:16 PM1/21/16
to vim_use
I can run vimdiff with multiple files, but I'd like to be able to use
vimdiff's "do", "diffu" features.
When I try to run "do", it gives me (obviously) an error:
"More than two buffers in diff mode, don't know which one to use"

If I have 3 files, and I'm on the center one, how do I tell it to "do"
the one on the left vs the one on the right?
Or does vimdiff only work with 2 files?

Thanks,
Ven

Ven Tadipatri

unread,
Jan 21, 2016, 2:53:51 PM1/21/16
to vim_use
Hmm...I guess I should have read the manual first.
:diffget <number>
seems to do the trick. So to answer my own question, I would do
:diffget 1 for the one on the left
and :diffget 3 for the one on the right.
But if anyone has any other useful pointers for using vimdiff, I would
appreciate it.

Thanks,
Ven

Simon Ruderich

unread,
Jan 22, 2016, 7:50:51 AM1/22/16
to vim...@googlegroups.com
On Thu, Jan 21, 2016 at 02:53:04PM -0500, Ven Tadipatri wrote:
> Hmm...I guess I should have read the manual first.
> :diffget <number>
> seems to do the trick. So to answer my own question, I would do
> :diffget 1 for the one on the left
> and :diffget 3 for the one on the right.
> But if anyone has any other useful pointers for using vimdiff, I would
> appreciate it.

You can use the count argument for dp an do, e.g. 1dp and 2do,
see :h dp

I'd really like to get better support for changes inside a line
in Vimdiff. At the moment Vimdiff doesn't create minimal changes
in this case. I recall there was a plugin which helped with that,
but I forgot its name. Anybody has an idea?

Regards
Simon
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
signature.asc

Christian Brabandt

unread,
Jan 22, 2016, 7:55:27 AM1/22/16
to vim...@googlegroups.com
Hi Simon!

On Fr, 22 Jan 2016, Simon Ruderich wrote:

> On Thu, Jan 21, 2016 at 02:53:04PM -0500, Ven Tadipatri wrote:
> > Hmm...I guess I should have read the manual first.
> > :diffget <number>
> > seems to do the trick. So to answer my own question, I would do
> > :diffget 1 for the one on the left
> > and :diffget 3 for the one on the right.
> > But if anyone has any other useful pointers for using vimdiff, I would
> > appreciate it.
>
> You can use the count argument for dp an do, e.g. 1dp and 2do,
> see :h dp
>
> I'd really like to get better support for changes inside a line
> in Vimdiff. At the moment Vimdiff doesn't create minimal changes
> in this case. I recall there was a plugin which helped with that,
> but I forgot its name. Anybody has an idea?

linediff?

Best,
Christian
--
Wir sind zu allem fähig, aber zu nichts zu gebrauchen.

Gary Johnson

unread,
Jan 22, 2016, 11:49:04 AM1/22/16
to vim...@googlegroups.com
I'm surprised you didn't mention EnhancedDiff
(http://www.vim.org/scripts/script.php?script_id=5121). I don't
think it looks inside lines, but it does a significantly better job
than the standard diff at aligning blocks of changed lines.

Regards,
Gary

JohnBeckett

unread,
Jan 22, 2016, 6:57:42 PM1/22/16
to vim_use, si...@ruderich.org
Simon Ruderich wrote:
> I'd really like to get better support for changes inside a line
> in Vimdiff. At the moment Vimdiff doesn't create minimal changes
> in this case. I recall there was a plugin which helped with that,
> but I forgot its name. Anybody has an idea?

diffchar gave excellent results when I used it at first:
http://www.vim.org/scripts/script.php?script_id=4932

However, after making a couple of minor edits and using :diffupdate the diffs were wrong. I forget exactly what the problem was, but I disabled the plugin when I missed seeing diffs that were not highlighted.

Fixing differences-within-a-line is badly needed, but a proper fix requires also fixing the problem that Vim cannot scroll very long lines. Diffs in a line are most needed when lines are very long (as in a paragraph of text), but such a line can only be displayed from its physical start and that prevents seeing diffs near the end of the long physical line.

I'm hoping someone will take up the suggestions mentioned in the following, and at the thread it links to:
http://vim.wikia.com/wiki/Vim_contribution_Ideas

John

Anton Daneyko

unread,
Apr 4, 2016, 3:30:12 PM4/4/16
to vim...@googlegroups.com
Simon Ruderich <simon <at> ruderich.org> writes:

>
> On Thu, Jan 21, 2016 at 02:53:04PM -0500, Ven Tadipatri wrote:
> > Hmm...I guess I should have read the manual first.
> > :diffget <number>
> > seems to do the trick. So to answer my own question, I would do
> > :diffget 1 for the one on the left
> > and :diffget 3 for the one on the right.
> > But if anyone has any other useful pointers for using vimdiff, I would
> > appreciate it.
>
> You can use the count argument for dp an do, e.g. 1dp and 2do,
> see :h dp
>
> I'd really like to get better support for changes inside a line
> in Vimdiff. At the moment Vimdiff doesn't create minimal changes
> in this case. I recall there was a plugin which helped with that,
> but I forgot its name. Anybody has an idea?
>
> Regards
> Simon

Dear Simon,

I have tried to use count arguments, but it does not work for me: I have
created three small test files and tried it there. I have made a 30 sec
screencast to show what I do: https://youtu.be/zWnYhX984PQ
I would appreciate it if you can give it a look and give me a hint about
why is this not working for me.

Best regards,
Anton




Reply all
Reply to author
Forward
0 new messages