I find myself frequently needing to compare two text blocks together without creating a file for each first, and then wishing to run a diff between the two of them.

Is there a tool I can use and just copy and paste both into empty buffers and then receive a diff between the two of them?


3 Answers 3


Meld (Wikipedia article) allows this.

When you open a new diff tab (Ctrl+n), a popup asks you to select two (or three) files. You can simply hit OK here, without selecting something.

It opens empty buffers, just like in a text editor, which allows you to paste (or type) text. The diff happens on the fly (while you paste/type/edit the text).

When you close the diff tab, the tool asks if you want to save the files.

Screenshot from http://meldmerge.org/features.html:

GUI of Meld, showing a diff of two files, highlighting different parts in red with blue background, and new lines with green background

  • 1
    I like meld. It also has an advantage of being cross-platform (I use it for my Windows development). You can select file comparison and then hit "blank comparison" to get the same result if you don't have an existing diff in progress
    – gabe3886
    Commented Sep 9, 2016 at 12:11
  • 1
    I had to press CTRL+N followed by clicking the File Comparison button, and then clicked the Blank comparison and than that did the trick.
    – leeand00
    Commented Sep 9, 2016 at 15:35

Another option is diffuse: http://diffuse.sourceforge.net/index.html

It opens to two blank panes by default, and you can paste whatever you like into each side.

example two-pane diff


Not the prettiest necessarily, but you could could do it with process substitution and heredocs:

diff <(cat <<EOF1
First text
and more
EOF1) <(cat <<EOF2
Second text
and more

would produce the output:

< First text
> Second text

and you could put whatever you like in each block of text of course.

Another option would be to use vim as in the answers here

The process I'd like with that one would be to do the following within vim:

  • insert text into current buffer
  • run :diffthis to include that window in the diff
  • run :vnew to get another window split vertically so they are side-by-side
  • insert text from second source
  • run :diffthis

presto, you've got your highlighted diff

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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