On windows, Notepad++ compare plugin let's you compare unsaved files. So to compare two texts copied from elsewhere, just make two new tabs and paste the texts. Compare plugin will happily compare line by line.

On Linux I havent found something similar. The closes is Kate, but you still have to save tmp1.txt and tmp2.txt , and remove the clutter when finished.

Does anybody know a compare app that just lets you paste two text blocks without saving files first?

all 17 comments

sorted by: hot top controversial new old
[–] 12 points 7 months ago (2 children)

meld allows you to start an empty comparison and to paste content into it without saving.

  • source
  • hideshow 2 child comments
  • [–] 10 points 7 months ago* (last edited 7 months ago)

    diff(1)

    Edit: oh I'm not sure you can paste two things into the terminal like that. Maybe kdiff3. If I'm really lazy I use this online one: https://editor.mergely.com/

  • source
  • [–] 5 points 7 months ago
    diff <<EOF  
    pastestuffhere  
    EOF  
    

    while this is running, paste the other stuff into terminal. I'm assuming diff reads stdin, if not given a filename.

  • source
  • [–] 4 points 7 months ago* (last edited 7 months ago) (3 children)

    I quickly wrote a script that uses kdialog from KDE to input text in a box, then writes both files to a temporary file, compares with diff and outputs the difference in a text box again. At the end it deletes the temporary files (if they are not deleted, they will be removed automatically with next system boot anyway). It's a quick and dirty script.

    I call it diffuse, for diff + use.

    #!/usr/bin/env bash
    
    title="Diff - Compare 2 Texts"
    output_size="720x720"
    
    file1="$(mktemp)"
    file2="$(mktemp)"
    file3="$(mktemp)"
    
    kdialog --title "${title} (input)" --textinputbox "Input Text 1" >> "${file1}"
    kdialog --title "${title} (input)" --textinputbox "Input Text 2" >> "${file2}"
    diff -- "${file1}" "${file2}" >> "${file3}"
    kdialog --title "${title} (diff)" --geometry "${output_size}" --textbox "${file3}"
    
    rm -- "${file1}"
    rm -- "${file2}"
    rm -- "${file3}"
    

    Edit: Forgot to mention the name of the script. Edit2: Totally wrong shebang line corrected.

  • source
  • hideshow 3 child comments
  • [–] 3 points 7 months ago

    For CLI, diff has already been mentioned; for a GUI application I'd recommend meld:

    https://meldmerge.org/

  • source
  • [–] 5 points 7 months ago
    [–] 2 points 7 months ago*

    vim's :diffthis

  • source
  • [–] 2 points 7 months ago (1 child)

    It’s not a very Linux-y answer, but VSC does allow you to compare 2 pages for differences. Those pages can be unsaved or saved files.

  • source
  • hideshow 1 child comment
  • [–] 2 points 7 months ago (2 children)

    You could always run NP++ via WINE if you can't find a native Linux solution that you like.

  • source
  • hideshow 2 child comments
  • [–] [S] 2 points 7 months ago (1 child)

    You're not wrong, but..... Yuck

    I have no hangups about using Wine for games and Windows only special snowflake apps. But a text editor through wine on Linux just feels dirty xD

  • source
  • parent
  • hideshow 1 child comment