Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

Your Answer


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.