Copy Find Result
-
I’m using a regex to Find lines in a file that’s open in NPP.
The Find result shows 189 hits.
And, that’s what seems to be displayed in the Find result window.
However, I don’t seem to be able to Copy those results to create a new file with Paste.
I was using Right Click and selecting Copy.
It appears CTRL+C would be more like it. But that doesn’t work as expected either.
I’m getting a few more lines than the original searched file when I Paste.
What I need is a file that’s the same as the Find result.Thanks!
-
@fred339 ,
After the Find In Files, your results window will have some number of lines.
- If you click on a single line and either RClick > Copy will copy just that single line.
- If you click on the line that says a file name, then the RClick > Copy action will copy the results from that file.
- If you do RClick > Select All then RClick > Copy , it will copy all the results, even across files.
Note that any of those three methods, using the RClick > Copy, will not copy the
Line ##:
prefix to any of the lines.If for some reason you wanted that, you could do a more normal selection (click and drag to select, rather than just clicking on the line), and use
Ctrl+C
to do the copy, then it will have theLine ##:
prefix included.If you need a file that is identical to the Find Results window, do a RClick > Select All, then use a standard
Ctrl+C
to copy. -
@fred339 said in Copy Find Result:
I’m getting a few more lines than the original searched file when I Paste
Maybe in addition to what @PeterJones said, you may want to right-click and do a Clear all BEFORE running a search. Then it is easy to copy only what you intend (I’m guessing this is the trouble you are having).
-
i thought this “copying of search results” would be possible somehow already , but i see no way doing it . i am able to copy whole lines , but not simply the matching characters in the lines . i thought it was possible with the search-mark-function to let all findings be marked , and then grab(copy/paste) these marked matches . but again i am facing the fact , that marking doesnt mean selecting . so i cannot get hands on all the direct matches of eg [a-z] {3} , instead only on the lines containing the matches .
-
@carypt said in Copy Find Result:
so i cannot get hands on all the direct matches of eg [a-z] {3} , instead only on the lines containing the matches .
Sounds like you might want to consider a destructive search. That’s where you use a regex to find the matches and leave ONLY that, everything else will be deleted. Or consider copying the find results and then work on that text in a similar fashion, removing all the “non-matching” text to leave ONLY what you wanted.
Often there are several ways of obtaining the result you want. It doesn’t always have to be a single shot answer. Often doing it in several steps will be easier to understand, especially if passing the job onto someone else going forward.
Terry
-
yes , as workaround i was thinking for a while on deleting everything around the search matches . but in regex i struggled on defining the unmatched for deleting only this . now i am exhausted with no good result , :)
-
-
Actually, I keep forgetting there is a relatively new command in Notepad++ to copy out marked text. It is found on the Mark tab. So, if you can mark the text you DO want, with a regex, you don’t have to be concerned about crafting a more complex regex to remove the text you don’t want.
-
Aaaahhhh ! yes , thats it . shame on me , i was not updated to 7.9.1 . i beg your pardon , but there is no excuse . shame on me