Search code examples
intellij-ideasearchcopy-paste

How to copy search results in IntelliJ to paste them elsewhere?


I would like to remember my team the ports used for debugging, for several projects.

A Ctrl-F in a directory, and I have my results under IntelliJ_2021.1.3 Ultimate I'm using,

enter image description here

but I have no way to paste them, like they are on this window, either with Ctrl-C or Ctrl-Ins , on another location in order to send a mail to my teammates.

Does a workaround exist, or has this feature been implemented in a later version I should try to upgrade to?


Solution

  • I don't think there is a simple and direct way to do what you want. However, there is a workaround:

    • Run your search, and then from the Find in Files window click the Open in Find Window button:

      Find

    • Right-click anywhere within that Find window listing the occurrences, then select Export to Text File from the context menu: Export

    • An Export Preview window will open, showing the search results in expanded hierarchical form, reflecting the structure under the directory you searched. Within that window you can select any contiguous portion of text, then right click and select Copy from the context menu: Copy

    • You can then paste the selected text into any other window, and massage the results as necessary: External

    Notes:

    • This is only a workaround because unfortunately I don't see a way to directly copy the results in your screen shot, in which each line shows a both a search occurrence and its file location. That information is still in the copied text, but it may take a bit of effort to get it in the form you want.
    • The Copy button in the Export Preview window ignores any text selection and blindly copies everything, so use Copy from the context menu instead if selecting a subset of the text.
    • I used IntelliJ IDEA 2023.1 EAP (Ultimate Edition). I don't know whether this functionality exists in your version.