Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How to "destructive vimdiff" ;) two files ?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christian Brabandt  
View profile  
 More options Oct 9 2012, 12:42 pm
From: Christian Brabandt <cbli...@256bit.org>
Date: Tue, 9 Oct 2012 18:42:14 +0200
Local: Tues, Oct 9 2012 12:42 pm
Subject: Re: How to "destructive vimdiff" ;) two files ?
Hi Ben!

On Di, 09 Okt 2012, Ben Fritz wrote:

> On Tuesday, October 9, 2012 8:10:29 AM UTC-5, Christian Brabandt
> wrote:

> > You need to loop over each line and get the diff_hlID() for that
> > position.

> > Each line, where diff_hlID() returns zero you need to delete.

> > Of course, you can do it in one step ;)

> > exe ':g/'. join(map(filter(range(1,line('$')), '!diff_hlID(v:val,
> > 0)'), '

> > ''\%''.v:val."l"'), '\|'). '/d'

> > But, this works only once, you can't do this for all buffers at the

> > same time, since after you changed the first buffer the syntax
> > highlighting

> > for the other will be completely different and there will be no more

> > items being in common at the following buffers.

> But, you could next undo the (single) change in the first buffer,
> repeat the process on the second buffer, then redo the change in the
> first buffer.

Even better, store the result for each window and execute it afterwards:

:let delete={}
:windo if &diff |:let delete[bufnr('')]=
join(map(filter(range(1,line('$')), '!diff_hlID(v:val, 0)'),
'''\%''.v:val."l"'), '\|')|endif
:windo if &diff | exe ":g/". delete[bufnr('')]."/d"|endif
:unlet delete

(each line starting with ':' is a single line, no linewraps)

regards,
Christian
--
Unter Rationalisierung verstehen die meisten Postminister, da man
die Geb hren laufend erh ht und die Zustellung st ndig verschlechtert.
                -- Cyril Northcote Parkinson


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.