Undo in vimdiff

434 views
Skip to first unread message

Benjamin R. Haskell

unread,
Nov 23, 2010, 12:25:25 PM11/23/10
to Vim
I'm finally setting out to create some useful mappings for the way I
like to use vimdiff. As part of this, I noticed that 'u' for undo
doesn't revert a :diffput command. It makes sense, since the change
technically occurs in a different buffer, but I was wondering whether
anyone had a clever mapping or workaround for that.

Really the main thing I'm adding is to map both '>' and '<' to
':.diffput', so that < and > feel like pushing lines from one buffer
into another. So, I guess I'd also be open to generally-useful vimdiff
mappings.

--
Best,
Ben

Christian Brabandt

unread,
Nov 23, 2010, 3:36:38 PM11/23/10
to Vim
Hi Benjamin!

On Di, 23 Nov 2010, Benjamin R. Haskell wrote:

> I'm finally setting out to create some useful mappings for the way I
> like to use vimdiff. As part of this, I noticed that 'u' for undo
> doesn't revert a :diffput command. It makes sense, since the change
> technically occurs in a different buffer, but I was wondering whether
> anyone had a clever mapping or workaround for that.

Hm, something like this may be:
nmap <expr> u histget('cmd',-2)=~'diffput'?'<C-W>pu<C-W>p':'u'

This probably won't get all corner cases, only when the last entered
command was :diffput.

> Really the main thing I'm adding is to map both '>' and '<' to
> ':.diffput', so that < and > feel like pushing lines from one buffer
> into another. So, I guess I'd also be open to generally-useful vimdiff
> mappings.

Oh, sounds interesting. Please share.

regards,
Christian
--
Das Sch�ne ist eine Manifestation geheimer Naturgesetze, die
uns ohne dessen Erscheinung ewig w�ren verborgen geblieben.
-- Goethe, Maximen und Reflektionen, Nr. 1166

Reply all
Reply to author
Forward
0 new messages