Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Moved lines are frequently annotated as deletes and adds but they can be shown as moved-from and moved-to instead.

Like in this screenshot of Notepad++.

Notepad++ diff'ing moved lines

share|improve this question
1  
I don't get what you want. Can you maybe demonstrate this with a small example? –  Bernhard Jun 28 '13 at 14:23
    
If you're looking for alternatives to vimdiff & diff just search this site, it's been pretty well covered already: unix.stackexchange.com/questions/tagged/diff –  slm Jun 28 '13 at 15:30
    
@Bernhard I posted a screen shot of Notepad++ feature of diff'ing moved lines. I'm looking for a cli alternative, preferably in vim. –  1.61803 Jun 28 '13 at 17:38
    
@slm, I want to diff moved lines preferably in vim. –  1.61803 Jun 28 '13 at 17:40
    
Wikipedia has a (short) list of tools that can do this. I have only used meld and it can't really detect moved lines (it kinda does) so take the list with a grain of salt. –  terdon Jun 28 '13 at 18:29
add comment

1 Answer 1

For its diff view, Vim relies on the output of the diff tool, which consists of line insertions (+) and deletions (-), but no moves. For convenience, Vim is able to highlight changes within a line, but it does not detect moves of (blocks of) lines, unlike Notepad++. You would need to implement this kind of feature yourself (e.g. using the sign column to show the moves).

share|improve this answer
    
could you please elaborate in detail on that implementation in order to mark your answer? –  1.61803 Jun 28 '13 at 19:21
    
You would need to get the changes (either by querying the Vim buffers for the lines highlighted in the Diff... highlight groups, or by running the diff tool yourself again, write a clever algorithm to detect the moves, and then use :sign place commands to attach the movement markers to the two diff buffers. –  Ingo Karkat Jun 28 '13 at 19:40
    
Alternatively, you could patch the Vim source code itself; getting at the diff information would be easier than in Vimscript. Such a patch (maybe using different colors rather than signs) could even be accepted into mainline Vim! –  Ingo Karkat Jun 28 '13 at 19:42
    
I rather hoped for a vimscript or a more feasible workaround. I leave it open for now. –  1.61803 Jun 28 '13 at 23:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.