How to copy search results in IntelliJ to paste them elsewhere?
Asked Answered
I

3

10

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?

Illegality answered 16/2, 2023 at 9:26 Comment(2)
You may use "Open in Find Window", select matches and run "Export to Text File" from context menu.Euphroe
Also see: How do I preserve search results in IntelliJ IDEA and Is there a way to copy search results as text?Jair
C
10

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.
Cording answered 16/2, 2023 at 19:45 Comment(0)
D
0

@skomisa You're solution also is available in IntelliJ IDEA Community Edition. The "Open in Find Tool Window" button is hard to find: it's the icon in the topright corner: enter image description here

Diandre answered 26/1 at 18:11 Comment(0)
J
0

For anyone looking to save results of searching usage of a method;

  1. On the search results popup, click on the icon on top right to open search results in bottom pane.

enter image description here

  1. In the search results that open up in bottom pane, right click on Usages or usages of base method in Project Files caption and click on Export to text file option in the popup menu

enter image description here

  1. In the save dialog box, edit the contents if required and change location of file by clicking on folder icon on top right (at the far end of file-name input text-box). Finally click on Save button

enter image description here

Jair answered 11/8 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.