Using IntelliJ to diff two arbitrary files












49














I'm really liking the IntelliJ diff tool. I'm wondering if it is possible to use this tool to diff two arbitrary files. I.e. files NOT in an IntelliJ project. Just pick two files in the file system and diff them? What about if I want to diff two strings? In my text editor, I'd just create two new documents, paste the text in and diff them, then not save the files when done. Is this possible?



Thanks










share|improve this question
























  • You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
    – LazyOne
    Jan 18 '13 at 12:13


















49














I'm really liking the IntelliJ diff tool. I'm wondering if it is possible to use this tool to diff two arbitrary files. I.e. files NOT in an IntelliJ project. Just pick two files in the file system and diff them? What about if I want to diff two strings? In my text editor, I'd just create two new documents, paste the text in and diff them, then not save the files when done. Is this possible?



Thanks










share|improve this question
























  • You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
    – LazyOne
    Jan 18 '13 at 12:13
















49












49








49


9





I'm really liking the IntelliJ diff tool. I'm wondering if it is possible to use this tool to diff two arbitrary files. I.e. files NOT in an IntelliJ project. Just pick two files in the file system and diff them? What about if I want to diff two strings? In my text editor, I'd just create two new documents, paste the text in and diff them, then not save the files when done. Is this possible?



Thanks










share|improve this question















I'm really liking the IntelliJ diff tool. I'm wondering if it is possible to use this tool to diff two arbitrary files. I.e. files NOT in an IntelliJ project. Just pick two files in the file system and diff them? What about if I want to diff two strings? In my text editor, I'd just create two new documents, paste the text in and diff them, then not save the files when done. Is this possible?



Thanks







intellij-idea diff






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 6 '17 at 18:53









Rumid

8032929




8032929










asked Jan 17 '13 at 19:20









Greg McGuffey

1,34831844




1,34831844












  • You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
    – LazyOne
    Jan 18 '13 at 12:13




















  • You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
    – LazyOne
    Jan 18 '13 at 12:13


















You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
– LazyOne
Jan 18 '13 at 12:13






You can: devnet.jetbrains.net/message/5299914#5299914 (search that forum for "diff command line" (or similar) for other similar threads)
– LazyOne
Jan 18 '13 at 12:13














8 Answers
8






active

oldest

votes


















52














Found this command line:



on MacOSX: (IDEA EAP 11)



/Applications/IntelliJ IDEA 11.app/Contents/MacOS/idea diff /Users/ben75/file1.txt /Users/ben75/file2.txt


On MacOSX it can't run when IDEA (11) is open.



on Windows: (IDEA EAP 12)



"C:Program Files (x86)JetBrainsIntelliJ IDEA 12.0binidea.exe" diff C:Usersben75file1.txt C:Usersben75file2.txt


It runs even if IDEA is already open.



I have trouble when trying to compare files with no extensions (or extensions that don't match )



Directly from IDEA (EAP 12)



Not so easy, but it works...




  • File > Open... > select "file1.txt"

  • File > Open... > select "file2.txt"

  • Create a "Favorite list" and add both files to this favorite list.
    (to do this : ctrl+right-click on file name tab in the editor > add
    to favorite > select the favorite list just created - see screenshot)

  • Finally, open the "Favorites" view (Alt+2 or click on it on the left or your IDEA windows).

  • Select both files

  • Right click : "compare two files" (or ctrl+D)


add to favorites






share|improve this answer



















  • 19




    Just CRTL + D on 2 files that are selected. No need struggling with favorites.
    – ses
    Oct 24 '13 at 20:09






  • 9




    The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
    – Timo Türschmann
    Mar 4 '16 at 11:25










  • I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
    – Tim Büthe
    Apr 7 '16 at 10:22










  • @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
    – John Smith
    Nov 30 '17 at 1:12










  • I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
    – Poma
    Jun 5 at 9:08



















37














IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.



This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.



View > Compare with Clipboard






share|improve this answer























  • Thanks for the info. I'll look into that!
    – Greg McGuffey
    Jan 24 '14 at 16:05






  • 1




    This is a really handy feature when migrating code from one Intellij project to another.
    – Dan Torrey
    Feb 6 '14 at 13:05










  • That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
    – MHarris
    Sep 5 '14 at 11:42










  • Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
    – Niall Connaughton
    Oct 13 '16 at 22:37



















24














Select 2 files in Project panel and press CTRL + D.



enter image description here






share|improve this answer



















  • 1




    how do you select 2 files that aren't in the project ?
    – ben75
    Oct 24 '13 at 20:20










  • I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
    – ses
    Oct 24 '13 at 20:38








  • 1




    Ok but the question was about files that aren't in the project.
    – ben75
    Oct 24 '13 at 20:46










  • They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
    – ses
    Oct 24 '13 at 20:55





















3














Yes you can (of course, if we are talking about text files). But probably you will need to create some project (just for opening there files).



Then your steps will be:



1) Add to created project file#1 and file#2.



2) Open file#1 in editor



3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor.



enter image description here



That's all. After p.3) a comparison windows will be opened.






share|improve this answer

















  • 1




    Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
    – Greg McGuffey
    Jan 17 '13 at 22:10





















2














In order to compare two files that both aren't in the project, the following works for me in IntelliJ IDEA Ultimate 14.1.7 on Windows:




  1. Open the first file in the IDE (either by dragging from Windows Explorer into the window, or by File / Open).

  2. In the view menu, choose "Compare With…"

  3. In the "Select Path" dialog that appears, select the second file (either directly, or by dragging from Windows Explorer into the dialog).


It then opens up in the traditional file comparison pane. If you try to edit one of the files, it presents the usual "Are you sure you want to edit a file that's not in your project" dialog, which one can accept if that's what one is trying to do.






share|improve this answer





















  • This is actually a lot easier than creating projects are using favorites list!
    – Ram
    Mar 29 at 7:56



















2














From the terminal, you can use the idea launcher directly like so:



# Windows
idea.exe diff path1 path2

# MacOS/Linux
idea diff path1 path2


At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:



# Create some files to diff
echo "This is line 1" > file1.txt
echo "This is line 2" > file2.txt

# Diff with IntelliJ
idea diff file1.txt file2.txt


Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:



# Diff with WebStorm
webstorm diff file1.txt file2.txt
# Diff with PyCharm
charm diff file1.txt file2.txt


Reference






share|improve this answer





























    1














    In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.






    share|improve this answer





























      0














      Since 2018.2, IntelliJ has officially supported it:



      For windows: Ctrl + Shift + A, then type "Open Blank Diff Viewer"



      enter image description here



      enter image description here



      For Mac: Cmd + Shift + A then type "Open Blank Diff Viewer"



      enter image description here



      enter image description here






      share|improve this answer























        Your Answer






        StackExchange.ifUsing("editor", function () {
        StackExchange.using("externalEditor", function () {
        StackExchange.using("snippets", function () {
        StackExchange.snippets.init();
        });
        });
        }, "code-snippets");

        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "1"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14386488%2fusing-intellij-to-diff-two-arbitrary-files%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        8 Answers
        8






        active

        oldest

        votes








        8 Answers
        8






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        52














        Found this command line:



        on MacOSX: (IDEA EAP 11)



        /Applications/IntelliJ IDEA 11.app/Contents/MacOS/idea diff /Users/ben75/file1.txt /Users/ben75/file2.txt


        On MacOSX it can't run when IDEA (11) is open.



        on Windows: (IDEA EAP 12)



        "C:Program Files (x86)JetBrainsIntelliJ IDEA 12.0binidea.exe" diff C:Usersben75file1.txt C:Usersben75file2.txt


        It runs even if IDEA is already open.



        I have trouble when trying to compare files with no extensions (or extensions that don't match )



        Directly from IDEA (EAP 12)



        Not so easy, but it works...




        • File > Open... > select "file1.txt"

        • File > Open... > select "file2.txt"

        • Create a "Favorite list" and add both files to this favorite list.
          (to do this : ctrl+right-click on file name tab in the editor > add
          to favorite > select the favorite list just created - see screenshot)

        • Finally, open the "Favorites" view (Alt+2 or click on it on the left or your IDEA windows).

        • Select both files

        • Right click : "compare two files" (or ctrl+D)


        add to favorites






        share|improve this answer



















        • 19




          Just CRTL + D on 2 files that are selected. No need struggling with favorites.
          – ses
          Oct 24 '13 at 20:09






        • 9




          The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
          – Timo Türschmann
          Mar 4 '16 at 11:25










        • I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
          – Tim Büthe
          Apr 7 '16 at 10:22










        • @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
          – John Smith
          Nov 30 '17 at 1:12










        • I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
          – Poma
          Jun 5 at 9:08
















        52














        Found this command line:



        on MacOSX: (IDEA EAP 11)



        /Applications/IntelliJ IDEA 11.app/Contents/MacOS/idea diff /Users/ben75/file1.txt /Users/ben75/file2.txt


        On MacOSX it can't run when IDEA (11) is open.



        on Windows: (IDEA EAP 12)



        "C:Program Files (x86)JetBrainsIntelliJ IDEA 12.0binidea.exe" diff C:Usersben75file1.txt C:Usersben75file2.txt


        It runs even if IDEA is already open.



        I have trouble when trying to compare files with no extensions (or extensions that don't match )



        Directly from IDEA (EAP 12)



        Not so easy, but it works...




        • File > Open... > select "file1.txt"

        • File > Open... > select "file2.txt"

        • Create a "Favorite list" and add both files to this favorite list.
          (to do this : ctrl+right-click on file name tab in the editor > add
          to favorite > select the favorite list just created - see screenshot)

        • Finally, open the "Favorites" view (Alt+2 or click on it on the left or your IDEA windows).

        • Select both files

        • Right click : "compare two files" (or ctrl+D)


        add to favorites






        share|improve this answer



















        • 19




          Just CRTL + D on 2 files that are selected. No need struggling with favorites.
          – ses
          Oct 24 '13 at 20:09






        • 9




          The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
          – Timo Türschmann
          Mar 4 '16 at 11:25










        • I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
          – Tim Büthe
          Apr 7 '16 at 10:22










        • @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
          – John Smith
          Nov 30 '17 at 1:12










        • I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
          – Poma
          Jun 5 at 9:08














        52












        52








        52






        Found this command line:



        on MacOSX: (IDEA EAP 11)



        /Applications/IntelliJ IDEA 11.app/Contents/MacOS/idea diff /Users/ben75/file1.txt /Users/ben75/file2.txt


        On MacOSX it can't run when IDEA (11) is open.



        on Windows: (IDEA EAP 12)



        "C:Program Files (x86)JetBrainsIntelliJ IDEA 12.0binidea.exe" diff C:Usersben75file1.txt C:Usersben75file2.txt


        It runs even if IDEA is already open.



        I have trouble when trying to compare files with no extensions (or extensions that don't match )



        Directly from IDEA (EAP 12)



        Not so easy, but it works...




        • File > Open... > select "file1.txt"

        • File > Open... > select "file2.txt"

        • Create a "Favorite list" and add both files to this favorite list.
          (to do this : ctrl+right-click on file name tab in the editor > add
          to favorite > select the favorite list just created - see screenshot)

        • Finally, open the "Favorites" view (Alt+2 or click on it on the left or your IDEA windows).

        • Select both files

        • Right click : "compare two files" (or ctrl+D)


        add to favorites






        share|improve this answer














        Found this command line:



        on MacOSX: (IDEA EAP 11)



        /Applications/IntelliJ IDEA 11.app/Contents/MacOS/idea diff /Users/ben75/file1.txt /Users/ben75/file2.txt


        On MacOSX it can't run when IDEA (11) is open.



        on Windows: (IDEA EAP 12)



        "C:Program Files (x86)JetBrainsIntelliJ IDEA 12.0binidea.exe" diff C:Usersben75file1.txt C:Usersben75file2.txt


        It runs even if IDEA is already open.



        I have trouble when trying to compare files with no extensions (or extensions that don't match )



        Directly from IDEA (EAP 12)



        Not so easy, but it works...




        • File > Open... > select "file1.txt"

        • File > Open... > select "file2.txt"

        • Create a "Favorite list" and add both files to this favorite list.
          (to do this : ctrl+right-click on file name tab in the editor > add
          to favorite > select the favorite list just created - see screenshot)

        • Finally, open the "Favorites" view (Alt+2 or click on it on the left or your IDEA windows).

        • Select both files

        • Right click : "compare two files" (or ctrl+D)


        add to favorites







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 19 '13 at 10:58

























        answered Jan 19 '13 at 8:32









        ben75

        23.3k666114




        23.3k666114








        • 19




          Just CRTL + D on 2 files that are selected. No need struggling with favorites.
          – ses
          Oct 24 '13 at 20:09






        • 9




          The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
          – Timo Türschmann
          Mar 4 '16 at 11:25










        • I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
          – Tim Büthe
          Apr 7 '16 at 10:22










        • @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
          – John Smith
          Nov 30 '17 at 1:12










        • I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
          – Poma
          Jun 5 at 9:08














        • 19




          Just CRTL + D on 2 files that are selected. No need struggling with favorites.
          – ses
          Oct 24 '13 at 20:09






        • 9




          The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
          – Timo Türschmann
          Mar 4 '16 at 11:25










        • I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
          – Tim Büthe
          Apr 7 '16 at 10:22










        • @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
          – John Smith
          Nov 30 '17 at 1:12










        • I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
          – Poma
          Jun 5 at 9:08








        19




        19




        Just CRTL + D on 2 files that are selected. No need struggling with favorites.
        – ses
        Oct 24 '13 at 20:09




        Just CRTL + D on 2 files that are selected. No need struggling with favorites.
        – ses
        Oct 24 '13 at 20:09




        9




        9




        The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
        – Timo Türschmann
        Mar 4 '16 at 11:25




        The question is explicitly about two ARBITRARY files, not already in the project view. You can't select two files that do not exist in any view, thus you have to create favorites for them.
        – Timo Türschmann
        Mar 4 '16 at 11:25












        I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
        – Tim Büthe
        Apr 7 '16 at 10:22




        I always struggled with this and started drag'n'drop these files into my project, just to compare them and delete them afterwards. Adding favorites is a nice workaround.
        – Tim Büthe
        Apr 7 '16 at 10:22












        @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
        – John Smith
        Nov 30 '17 at 1:12




        @TimoTürschmann .bashrc <=== alias idiff='"C:Program FilesJetBrainsIntelliJ IDEA Community Edition 2017.2.2binidea64.exe" diff '
        – John Smith
        Nov 30 '17 at 1:12












        I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
        – Poma
        Jun 5 at 9:08




        I've added this function to my zsh config idiff() { "/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" diff "$(realpath $1)" "$(realpath $2)" }, it allows to execute idiff on relative paths too
        – Poma
        Jun 5 at 9:08













        37














        IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.



        This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.



        View > Compare with Clipboard






        share|improve this answer























        • Thanks for the info. I'll look into that!
          – Greg McGuffey
          Jan 24 '14 at 16:05






        • 1




          This is a really handy feature when migrating code from one Intellij project to another.
          – Dan Torrey
          Feb 6 '14 at 13:05










        • That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
          – MHarris
          Sep 5 '14 at 11:42










        • Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
          – Niall Connaughton
          Oct 13 '16 at 22:37
















        37














        IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.



        This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.



        View > Compare with Clipboard






        share|improve this answer























        • Thanks for the info. I'll look into that!
          – Greg McGuffey
          Jan 24 '14 at 16:05






        • 1




          This is a really handy feature when migrating code from one Intellij project to another.
          – Dan Torrey
          Feb 6 '14 at 13:05










        • That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
          – MHarris
          Sep 5 '14 at 11:42










        • Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
          – Niall Connaughton
          Oct 13 '16 at 22:37














        37












        37








        37






        IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.



        This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.



        View > Compare with Clipboard






        share|improve this answer














        IntelliJ Idea 13 has a feature labeled Compare with Clipboard. This feature compares the current open file with a version that you have copied into your clipboard. It's a great, easy way to compare and merge two files easily. It can also be used to compare two arbitrary blocks of code. Can't figure out why one block works and another does not? Use this feature.



        This option is present under View > Compare with Clipboard. I assigned an easy to remember keyboard shortcut to give me quick access to this feature.



        View > Compare with Clipboard







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 8 '14 at 18:28

























        answered Jan 21 '14 at 23:42









        Dan Torrey

        9161020




        9161020












        • Thanks for the info. I'll look into that!
          – Greg McGuffey
          Jan 24 '14 at 16:05






        • 1




          This is a really handy feature when migrating code from one Intellij project to another.
          – Dan Torrey
          Feb 6 '14 at 13:05










        • That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
          – MHarris
          Sep 5 '14 at 11:42










        • Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
          – Niall Connaughton
          Oct 13 '16 at 22:37


















        • Thanks for the info. I'll look into that!
          – Greg McGuffey
          Jan 24 '14 at 16:05






        • 1




          This is a really handy feature when migrating code from one Intellij project to another.
          – Dan Torrey
          Feb 6 '14 at 13:05










        • That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
          – MHarris
          Sep 5 '14 at 11:42










        • Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
          – Niall Connaughton
          Oct 13 '16 at 22:37
















        Thanks for the info. I'll look into that!
        – Greg McGuffey
        Jan 24 '14 at 16:05




        Thanks for the info. I'll look into that!
        – Greg McGuffey
        Jan 24 '14 at 16:05




        1




        1




        This is a really handy feature when migrating code from one Intellij project to another.
        – Dan Torrey
        Feb 6 '14 at 13:05




        This is a really handy feature when migrating code from one Intellij project to another.
        – Dan Torrey
        Feb 6 '14 at 13:05












        That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
        – MHarris
        Sep 5 '14 at 11:42




        That's really cool, I looked for something like that under the Edit menu, and when I couldn't find it, assumed IntelliJ didn't have it! :)
        – MHarris
        Sep 5 '14 at 11:42












        Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
        – Niall Connaughton
        Oct 13 '16 at 22:37




        Do you know if it's possible to open up a blank diff window to allow comparisons of two different pieces of copy/pasted text? I do this all the time, but now working with Mac it seems all the diff tools want to work with files only. It's useful for grabbing bits of text out of documents to see what's changed, diffing just one function in a file, etc.
        – Niall Connaughton
        Oct 13 '16 at 22:37











        24














        Select 2 files in Project panel and press CTRL + D.



        enter image description here






        share|improve this answer



















        • 1




          how do you select 2 files that aren't in the project ?
          – ben75
          Oct 24 '13 at 20:20










        • I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
          – ses
          Oct 24 '13 at 20:38








        • 1




          Ok but the question was about files that aren't in the project.
          – ben75
          Oct 24 '13 at 20:46










        • They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
          – ses
          Oct 24 '13 at 20:55


















        24














        Select 2 files in Project panel and press CTRL + D.



        enter image description here






        share|improve this answer



















        • 1




          how do you select 2 files that aren't in the project ?
          – ben75
          Oct 24 '13 at 20:20










        • I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
          – ses
          Oct 24 '13 at 20:38








        • 1




          Ok but the question was about files that aren't in the project.
          – ben75
          Oct 24 '13 at 20:46










        • They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
          – ses
          Oct 24 '13 at 20:55
















        24












        24








        24






        Select 2 files in Project panel and press CTRL + D.



        enter image description here






        share|improve this answer














        Select 2 files in Project panel and press CTRL + D.



        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited May 19 '16 at 4:30









        Jossef Harush

        15.1k45672




        15.1k45672










        answered Oct 24 '13 at 20:12









        ses

        6,6332092173




        6,6332092173








        • 1




          how do you select 2 files that aren't in the project ?
          – ben75
          Oct 24 '13 at 20:20










        • I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
          – ses
          Oct 24 '13 at 20:38








        • 1




          Ok but the question was about files that aren't in the project.
          – ben75
          Oct 24 '13 at 20:46










        • They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
          – ses
          Oct 24 '13 at 20:55
















        • 1




          how do you select 2 files that aren't in the project ?
          – ben75
          Oct 24 '13 at 20:20










        • I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
          – ses
          Oct 24 '13 at 20:38








        • 1




          Ok but the question was about files that aren't in the project.
          – ben75
          Oct 24 '13 at 20:46










        • They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
          – ses
          Oct 24 '13 at 20:55










        1




        1




        how do you select 2 files that aren't in the project ?
        – ben75
        Oct 24 '13 at 20:20




        how do you select 2 files that aren't in the project ?
        – ben75
        Oct 24 '13 at 20:20












        I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
        – ses
        Oct 24 '13 at 20:38






        I put in there by drag and drop to the project, to some dedicated folder. Then just select them - by CTRL key on keyboard + right click by mouse on the table. (I use idea 12 just in case). Make sure you select 2 files but not 3 or 1. My point is - no need to use favorites.
        – ses
        Oct 24 '13 at 20:38






        1




        1




        Ok but the question was about files that aren't in the project.
        – ben75
        Oct 24 '13 at 20:46




        Ok but the question was about files that aren't in the project.
        – ben75
        Oct 24 '13 at 20:46












        They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
        – ses
        Oct 24 '13 at 20:55






        They are not to be in the project eventually (they are just temporary guests if you will). Otherwise: It might be costly for some guys like me to type paths in command line, pointing two files (especially if paths are long). Maybe you are right. This depends on point of view what is meaning 'not in the project'. I suppose they are guests to be compared, nothing wrong if I drop them there.
        – ses
        Oct 24 '13 at 20:55













        3














        Yes you can (of course, if we are talking about text files). But probably you will need to create some project (just for opening there files).



        Then your steps will be:



        1) Add to created project file#1 and file#2.



        2) Open file#1 in editor



        3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor.



        enter image description here



        That's all. After p.3) a comparison windows will be opened.






        share|improve this answer

















        • 1




          Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
          – Greg McGuffey
          Jan 17 '13 at 22:10


















        3














        Yes you can (of course, if we are talking about text files). But probably you will need to create some project (just for opening there files).



        Then your steps will be:



        1) Add to created project file#1 and file#2.



        2) Open file#1 in editor



        3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor.



        enter image description here



        That's all. After p.3) a comparison windows will be opened.






        share|improve this answer

















        • 1




          Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
          – Greg McGuffey
          Jan 17 '13 at 22:10
















        3












        3








        3






        Yes you can (of course, if we are talking about text files). But probably you will need to create some project (just for opening there files).



        Then your steps will be:



        1) Add to created project file#1 and file#2.



        2) Open file#1 in editor



        3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor.



        enter image description here



        That's all. After p.3) a comparison windows will be opened.






        share|improve this answer












        Yes you can (of course, if we are talking about text files). But probably you will need to create some project (just for opening there files).



        Then your steps will be:



        1) Add to created project file#1 and file#2.



        2) Open file#1 in editor



        3) Right click mouse in left menu (project files browser) on file#2 and find menu-item Compare File with Editor.



        enter image description here



        That's all. After p.3) a comparison windows will be opened.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 17 '13 at 19:53









        Andremoniy

        21.7k673155




        21.7k673155








        • 1




          Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
          – Greg McGuffey
          Jan 17 '13 at 22:10
















        • 1




          Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
          – Greg McGuffey
          Jan 17 '13 at 22:10










        1




        1




        Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
        – Greg McGuffey
        Jan 17 '13 at 22:10






        Thanks. I knew I could do the diff that way. I was attempting to figure out if I could skip going through a project and just do the diff. I suppose I could ask another question for a recommendation for a text editor that has a diff tool like intelliJ.
        – Greg McGuffey
        Jan 17 '13 at 22:10













        2














        In order to compare two files that both aren't in the project, the following works for me in IntelliJ IDEA Ultimate 14.1.7 on Windows:




        1. Open the first file in the IDE (either by dragging from Windows Explorer into the window, or by File / Open).

        2. In the view menu, choose "Compare With…"

        3. In the "Select Path" dialog that appears, select the second file (either directly, or by dragging from Windows Explorer into the dialog).


        It then opens up in the traditional file comparison pane. If you try to edit one of the files, it presents the usual "Are you sure you want to edit a file that's not in your project" dialog, which one can accept if that's what one is trying to do.






        share|improve this answer





















        • This is actually a lot easier than creating projects are using favorites list!
          – Ram
          Mar 29 at 7:56
















        2














        In order to compare two files that both aren't in the project, the following works for me in IntelliJ IDEA Ultimate 14.1.7 on Windows:




        1. Open the first file in the IDE (either by dragging from Windows Explorer into the window, or by File / Open).

        2. In the view menu, choose "Compare With…"

        3. In the "Select Path" dialog that appears, select the second file (either directly, or by dragging from Windows Explorer into the dialog).


        It then opens up in the traditional file comparison pane. If you try to edit one of the files, it presents the usual "Are you sure you want to edit a file that's not in your project" dialog, which one can accept if that's what one is trying to do.






        share|improve this answer





















        • This is actually a lot easier than creating projects are using favorites list!
          – Ram
          Mar 29 at 7:56














        2












        2








        2






        In order to compare two files that both aren't in the project, the following works for me in IntelliJ IDEA Ultimate 14.1.7 on Windows:




        1. Open the first file in the IDE (either by dragging from Windows Explorer into the window, or by File / Open).

        2. In the view menu, choose "Compare With…"

        3. In the "Select Path" dialog that appears, select the second file (either directly, or by dragging from Windows Explorer into the dialog).


        It then opens up in the traditional file comparison pane. If you try to edit one of the files, it presents the usual "Are you sure you want to edit a file that's not in your project" dialog, which one can accept if that's what one is trying to do.






        share|improve this answer












        In order to compare two files that both aren't in the project, the following works for me in IntelliJ IDEA Ultimate 14.1.7 on Windows:




        1. Open the first file in the IDE (either by dragging from Windows Explorer into the window, or by File / Open).

        2. In the view menu, choose "Compare With…"

        3. In the "Select Path" dialog that appears, select the second file (either directly, or by dragging from Windows Explorer into the dialog).


        It then opens up in the traditional file comparison pane. If you try to edit one of the files, it presents the usual "Are you sure you want to edit a file that's not in your project" dialog, which one can accept if that's what one is trying to do.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 6 '17 at 17:12









        Peter Cooper Jr.

        6,49432742




        6,49432742












        • This is actually a lot easier than creating projects are using favorites list!
          – Ram
          Mar 29 at 7:56


















        • This is actually a lot easier than creating projects are using favorites list!
          – Ram
          Mar 29 at 7:56
















        This is actually a lot easier than creating projects are using favorites list!
        – Ram
        Mar 29 at 7:56




        This is actually a lot easier than creating projects are using favorites list!
        – Ram
        Mar 29 at 7:56











        2














        From the terminal, you can use the idea launcher directly like so:



        # Windows
        idea.exe diff path1 path2

        # MacOS/Linux
        idea diff path1 path2


        At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:



        # Create some files to diff
        echo "This is line 1" > file1.txt
        echo "This is line 2" > file2.txt

        # Diff with IntelliJ
        idea diff file1.txt file2.txt


        Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:



        # Diff with WebStorm
        webstorm diff file1.txt file2.txt
        # Diff with PyCharm
        charm diff file1.txt file2.txt


        Reference






        share|improve this answer


























          2














          From the terminal, you can use the idea launcher directly like so:



          # Windows
          idea.exe diff path1 path2

          # MacOS/Linux
          idea diff path1 path2


          At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:



          # Create some files to diff
          echo "This is line 1" > file1.txt
          echo "This is line 2" > file2.txt

          # Diff with IntelliJ
          idea diff file1.txt file2.txt


          Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:



          # Diff with WebStorm
          webstorm diff file1.txt file2.txt
          # Diff with PyCharm
          charm diff file1.txt file2.txt


          Reference






          share|improve this answer
























            2












            2








            2






            From the terminal, you can use the idea launcher directly like so:



            # Windows
            idea.exe diff path1 path2

            # MacOS/Linux
            idea diff path1 path2


            At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:



            # Create some files to diff
            echo "This is line 1" > file1.txt
            echo "This is line 2" > file2.txt

            # Diff with IntelliJ
            idea diff file1.txt file2.txt


            Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:



            # Diff with WebStorm
            webstorm diff file1.txt file2.txt
            # Diff with PyCharm
            charm diff file1.txt file2.txt


            Reference






            share|improve this answer












            From the terminal, you can use the idea launcher directly like so:



            # Windows
            idea.exe diff path1 path2

            # MacOS/Linux
            idea diff path1 path2


            At least for MacOS (I'm not certain of Windows), if you've created the Command-line Launcher via "Tools -> Create Command-line Launcher..." it's as simple as the following:



            # Create some files to diff
            echo "This is line 1" > file1.txt
            echo "This is line 2" > file2.txt

            # Diff with IntelliJ
            idea diff file1.txt file2.txt


            Note this works with other JetBrains applications as well; for example, using WebStorm or PyCharm:



            # Diff with WebStorm
            webstorm diff file1.txt file2.txt
            # Diff with PyCharm
            charm diff file1.txt file2.txt


            Reference







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 9 at 23:26









            Joshua Hansen

            6816




            6816























                1














                In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.






                share|improve this answer


























                  1














                  In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.






                  share|improve this answer
























                    1












                    1








                    1






                    In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.






                    share|improve this answer












                    In IntelliJ IDEA 2018.2, you can open an empty Differences Viewer and paste any text you want to compare in its left and right panels. The new Open Blank Diff Viewer action can be found in the Find Action dialog.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jul 27 at 13:09









                    Ruslan

                    1,076723




                    1,076723























                        0














                        Since 2018.2, IntelliJ has officially supported it:



                        For windows: Ctrl + Shift + A, then type "Open Blank Diff Viewer"



                        enter image description here



                        enter image description here



                        For Mac: Cmd + Shift + A then type "Open Blank Diff Viewer"



                        enter image description here



                        enter image description here






                        share|improve this answer




























                          0














                          Since 2018.2, IntelliJ has officially supported it:



                          For windows: Ctrl + Shift + A, then type "Open Blank Diff Viewer"



                          enter image description here



                          enter image description here



                          For Mac: Cmd + Shift + A then type "Open Blank Diff Viewer"



                          enter image description here



                          enter image description here






                          share|improve this answer


























                            0












                            0








                            0






                            Since 2018.2, IntelliJ has officially supported it:



                            For windows: Ctrl + Shift + A, then type "Open Blank Diff Viewer"



                            enter image description here



                            enter image description here



                            For Mac: Cmd + Shift + A then type "Open Blank Diff Viewer"



                            enter image description here



                            enter image description here






                            share|improve this answer














                            Since 2018.2, IntelliJ has officially supported it:



                            For windows: Ctrl + Shift + A, then type "Open Blank Diff Viewer"



                            enter image description here



                            enter image description here



                            For Mac: Cmd + Shift + A then type "Open Blank Diff Viewer"



                            enter image description here



                            enter image description here







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Nov 20 at 21:39

























                            answered Nov 20 at 16:04









                            nxhoaf

                            5,45283138




                            5,45283138






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.





                                Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                Please pay close attention to the following guidance:


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14386488%2fusing-intellij-to-diff-two-arbitrary-files%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                404 Error Contact Form 7 ajax form submitting

                                How to know if a Active Directory user can login interactively

                                TypeError: fit_transform() missing 1 required positional argument: 'X'