Collapse function - how to copy just the collapsed results from results window



  • Hi Notepad++ colleagues - I’m doing research, I found the result set I need, but I want to copy the collapsed text without the details (uncollapsed view). In searching for a ‘string’ in a series of files, I get the details and the file-name that detail resides. I just want to copy the file name from the collapsed view but, NP provides all the detail too when I copy all. It’s too much to work with… Can you help? Thanks in advance.



  • Hello @J-Blue,

    the only way I know at the moment is to

    • uncollapse all in search result window.
    • Select everything without the first line manually
    • copy
    • paste it in a new empty window
    • open find/replace dialog select mark tab
    • check bookmark line
    • in find the path which is unique enough like C:\
    • press mark all
      -> now all lines which are of interest for you should have been marked
    • goto Search->Bookmark and select Remove all unmarked lines.

    Sounds like this are many steps but actually aren’t.

    Cheers
    Claudia



  • Hello J Blue,

    Luckily, there’s a solution that implies to use a search/replacement with a regular expression, in order to delete all the lines, different from each path files displayed in the Find Result panel :-)

    So, follow the few steps, below :

    • Create a new file with the menu option File - New or use the shortcut CTRL + N

    • Perform your search/replacement and click on the Find All in All Opened documents or on the Find All button

    • Left click on any line, of the Find result panel, which contains all your matches, distributed on several files

    • Select all the contents of the Find result panel by typing the shortcut CTRL + A ( DON’T use the menu option Edit - Select All, which acts on the main editor )

    • Paste it, in the new file, previously created, EXCLUSIVELY by left clicking on the selection of the Find result panel and dragging it over the empty window of the new file

    • Move at the very beginning of this new file or use the CTRL + Org shortcut

    • Open the Replace dialog or use the CTRL + H shortcut

    • Type in the Find what zone, the regex (?-is)(?:(?:^Search "|\tLine).*\R| \(\d+ hits?\))

    • Leave the Replace with zone empty

    • Set the Regular expression search mode

    • Finally, click on the Replace All button

    Et voilà !! You only get the absolute paths of all the files, containing your initial search !!

    Note :

    If you prefer to keep the first line, which shows the search contents and the statistics, about the hits and the files involved, just change the above regex with the regex (?-is)(?:\tLine.*\R| \(\d+ hits?\))

    Best Regards,

    guy038

    P.S. :

    It’s quite bed time, now, in France ( 02h40 ! ) But, tomorrow, I’ll give some additional explanations on these regexes, if necessary !



  • Thanks Claudia - * ** press mark all - ***unfortunately, the filename is not being copied as part of my select all into the new file, so it can’t be marked. The file name only appears in my results panel, is there a setting I need to check for using the results panel in a new file? ARRRGGH



  • Thanks Guy038 - *** Paste it, in the new file, previously created - ***the results panel is not being copied into the new file, it seems my results panel is not cooperating with normal editing functions, is there something I need to set to use the results panel in an editor?



  • Hi J Blue,

    Oh ! I forgot to tell you that you must exclusively use the mouse to achieve the paste operation !

    So, the 5th step of my method, described in my previous post, should be :

    • Paste it, in the new file, previously created, EXCLUSIVELY by left clicking on the selection of the Find result panel and dragging it over the empty window of the new file

    BTW, I also updated, accordingly, my previous post, of course !

    It should work fine !

    Cheers,

    guy038



  • VOILA indeed, that worked! Thank you,



  • Hi J Blue,

    I’m pleased that you’ve got the job done, at last !

    Just some explanations about the regex (?-is)(?:(?:^Search "|\tLine).*\R| \(\d+ hits?\))

    Moreover, thinking again about it, I slightly shorten its syntax and correct a possible error :-)


    So, the final and exact regex becomes (?-is)(?:^(?:Search "|\t).+\R| \(\d+ hits?\)$)

    • The two modifiers, (?-is) at the beginning of the regex ensure that this regex will be performed with the options :

      • No insensitive (?-i)
      • No Single line (?-s)

    whatever you set/unset the corresponding options Match case and . matches newline, in the Find/Replace dialog

    • The two characters ?: at the beginning of a group n (?:........) prevents the regex engine from backing up this group as the back-reference \n, for further use, in the search or the replacement regex

    • As a file CAN’T contain a Tabulation character in its name, neither a double quotes " character and, as any line found in the Find result panel, begins with a Tabulation character, the search, from the beginning of a line, of the strings Search " or \t followed by any non empty range of characters ( .+ ), followed, itself, by the End of Line character(s) ( \R ), will delete any line, different from an absolute pathname of a file ! ( (?:^(?:Search "|\t).+\R )

    • Then, we just have to suppress the string (## hits), at the end of each absolute pathname. As the round brackets must be escaped in order to be searched as literals, this part can be achieved with the regex \(\d+ hits?\)$, with a space before the characters \(.

    • We need to add the assertion $ meaning End of Line, just in case your would have created a file with the exact name, let’s say, Test (17 hits). Without the anchor $, it would delete the end of the filename ( Drive_Letter:\...\...\Test ) !

    • Finally, if you prefer to keep the first line, which shows the search contents and the statistics, about the hits and the files involved, just change the above regex by the regex (?-is)(?:^\t.+\R| \(\d+ hits?\)$)

    Cheers,

    guy038



  • And, Claudia’s suggestion works too. The key is mouse drag results to new file, thanks.


Log in to reply