Select all marked text
-
Re: Is there a way to select all marked text?
I came across the old post above since I was having the same question. As you were asking why someone would want that, I had this scenerio:first I looked up specific parts of a text with a regex.
After that I want to to a search/replace in only those found parts. Now I can highlight or copy those parts, but there is no way to select them.
In that case it would be handy to just be able to select all marked text. -
As you read that post, did you also read the answer? In that case and your post, the final reason to do so seems a bit unclear (to me).
If a regex can select text which is all you wish to edit, then the regex can also alter the text which was selected with the addition of the “replace with” field being filled with what you require.
If the regex just selects a line that has some text you are searching for and you want to edit something (else) in that line, you could firstly prepend every line with a line number (column editor, number to insert). Use the regex to “mark” which lines, cut those marked lines and paste into another (new) tab. Edit those lines then paste them back and re-sort by the line numbers, then remove those line numbers.
These are just a couple of ideas. As I said, I’m unclear on what your intention is. But often I find it works better when the problem has been broken down into more easily managed chunks. Then work on each step in turn.
Terry
-
The simple answer is: there is not a Notepad++ feature to select text after the Mark action has been completed.
You haven’t specified what you will do with the selected text after you select it. @Terry-R enumerated the major actions one normally takes after doing a selection (copy, delete, replace, or typeover), all of which can be handled through the Replace or Mark dialogs, or the Search>Bookmark> submenu if you bookmarked-while-Marking).
So what’s specific about your need that you need there to be an actual selection after it’s marked, rather than doing one of the other described actions? -
Maybe I can see it… You mark text via several different operations, as you evaluate data. Then you decide, or you always knew from the beginning, that anything you’ve marked you will need to delete, but for some reason you didn’t want to do the deletion until you were done marking… only to find there is no way now to delete that text. I’ve never had such a scenario, but maybe I could see it occurring.
But, there are a limited number of things you can do with selected text. Deleting and typing-to-fill each occurrence with the same things are the obvious ones.
-
@Alan-Kilborn
I have situation where I’m deleting first occurrence of some pattern from the beginning of line ^\d+/\d\t and using replace to nothing method and after first replacement notepad++ don’t go to next line but finds another occurrence in the same line. Search method works ok as it don’t delete any part of original string. I need a way to select marked text. -
@Tomasz-Sałek said in Select all marked text:
after first replacement notepad++ don’t go to next line but finds another occurrence in the same line
I can’t tell much from the mangled regex you supplied (an no data was supplied).
But, if you have:
aaaa aaaa aaaa
and you want to remove the first
a
from each line, the way to do it is:Find:
(?-s)^a(.+)
Replace:${1}
Perhaps you can use the wisdom from that approach in your own problem.
-
@Alan-Kilborn Thank you. This works but I feel this is only workaround of problem. I workaround this problem as well by replacing founded pattern by some particular pattern or sign and then replacing it with nothing. More intuitive would be just an option to select marked text (for my mind marking and selecting is the same).
-
@Tomasz-Sałek said in Select all marked text:
@Alan-Kilborn Thank you. This works but I feel this is only workaround of problem.
No, you just were pretty vague in describing your problem, so he had to try to guess the meaning that you intended – and based on your next sentence, I think he miraculously did guess correctly, but then you didn’t like his answer.
I workaround this problem as well by replacing founded pattern by some particular pattern or sign and then replacing it with nothing.
How is that in any way “selecting”? It does not sound like “selecting” is really your end goal.
If you really want to delete, as your “workaround” implies, and as Alan interpreted, then the right thing to do is a search with replace-with-nothing (or in Alan’s example, replace-with-less-than-matched) – and if that’s your goal, it’s not a “workaround”, it is the correct solution.
More intuitive would be just an option to select marked text
The FIND dialog selects matching text; if you want to SELECT rather than search-and-replace, then just use FIND, not REPLACE.
(for my mind marking and selecting is the same).
Then you need to update your mind, because in Notepad++ the two are separate concepts. “Marking” is just adding temporary color for easy visual reference; “selecting” is moving the selection-region to cover one or more characters, thereby directly affecting what is immediately going to be edited by your next typing or menu/keyboard command.
-
It looks like Alan knew what I meant so there was enough portion of information.
@PeterJones said in Select all marked text:
If you really want to delete, as your “workaround” implies, and as Alan interpreted, then the right thing to do is a search with replace-with-nothing (or in Alan’s example, replace-with-less-than-matched) – and if that’s your goal, it’s not a “workaround”, it is the correct solution.
The problem is that search with replace-with-nothing is looping because of replace algorithm which search first occurrence, do first replacement and process modified text from beginning. This should rather do search on entire text an then replace all occurrences one by one. This would avoid of looping.
@PeterJones said in Select all marked text:
The FIND dialog selects matching text; if you want to SELECT rather than search-and-replace, then just use FIND, not REPLACE.
I think FIND don’t work like this. FIND open new subwindow with all lines with searched text.
@PeterJones said in Select all marked text:
Then you need to update your mind, because in Notepad++ the two are separate concepts. “Marking” is just adding temporary color for easy visual reference; “selecting” is moving the selection-region to cover one or more characters, thereby directly affecting what is immediately going to be edited by your next typing or menu/keyboard command.
I know what this means but “just marking” is not very usefull as user can not manipulate such a marked text.
-
@Tomasz-Sałek said in Select all marked text:
The problem is that search with replace-with-nothing is looping because of replace algorithm which search first occurrence, do first replacement and process modified text from beginning. This should rather do search on entire text an then replace all occurrences one by one. This would avoid of looping.
That approach would work for Replace All.
However, it doesn’t work for (single step) Replace.
I think FIND don’t work like this. FIND open new subwindow with all lines with searched text.
No, a Find All is the one that opens a Search results subwindow to display the output. There are several types of “Find All”: in current document, in files, in all open tabs.
“just marking” is not very usefull as user can not manipulate such a marked text
Selecting text isn’t all that useful either (because, what are your possibilities for what you’re going to do next with that selected text – not many useful possibilities).
-
@Alan-Kilborn This is a base of a problem. I always think about Find All and Replace All because it’s a only useful thing when processing several hundreds/thousands lines of data. I’m geodesist so I’m often processing a lot of point numbers, coordinates, parcel numbers etc.
Selecting, copying and pasting is a basic, common, easiest and fastest way to interact with others programs so I think this would be very helpful. -
@Tomasz-Sałek said in Select all marked text:
Selecting, copying and pasting
Search > Mark, ☑ Bookmark Lines, input FIND regex, Mark All, exit dialog. Search > Bookmark > Copy Bookmarked Lines. And there you have it – the found text is copied, so you can now paste it at will. (Addenda 2: or, right, the Copy Marked Text button that Alan mentioned after I posted; don’t know why I forgot that one.)
Addenda 1: Or, if you prefer the Find All still, you can copy the results out of the Search Results window/panel in one of two ways described in the User Manual, one or the other of which you might prefer more.
-
@Tomasz-Sałek said in Select all marked text:
Selecting, copying and pasting is a basic, common, easiest and fastest way to interact with others programs
I can appreciate the notion of getting the results of a search as input to another program.
Let’s consider Find All in Current Document (in regex mode because that’s really the only relevant search mode). If you could do that Find-All and have all matches as selected text (to be clear, that’s called multi-selected text), the way a standard Copy currently works would be to run all the matched text together in one big blob. That’s why marking text and using Copy Marked Text is superior; you get a delimiter (line-endings) between the matches.
So, really, there are a few hurdles to the problem as I understand it. Having text multi-selected as the result of a Find-All is only one of them.
EDIT: Seeing Peter’s input after writing the above, my comment is: That works if you are always interested in whole-line data. But if you need partial-line text pieces, there’s a problem (at least one).
-
@Tomasz-Sałek said in Select all marked text:
I have situation where I’m deleting first occurrence of some pattern from the beginning of line ^\d+/\d\t and using replace to nothing method and after first replacement notepad++ don’t go to next line but finds another occurrence in the same line. Search method works ok as it don’t delete any part of original string. I need a way to select marked text.
It is possible that you would like the Search… function in my Columns++ plugin. This search works within an indicated region (which can be “marked text,” “styled text” or a custom indicator), and the drop-down arrow on the Count button offers a Select All function. There is documentation here. For the specific case you described, I believe you could use Select All, then just close the dialog and press the Delete key.
Aside: Watch the preview window when posting or commenting to be sure what will show matches what you meant to write. In quoting you, it appears that you meant your regular expression to be
^\d+\/*\d*\t
; but it didn’t come out that way, because the asterisks were interpreted as signaling italics and the backslash before the forward slash was dropped (which you may or may not have intended). In this case, using three “backticks” (```) on either side of the regular expression works to show it as “code” — however, there are exceptions to the exceptions to the exceptions in this forum software, so there is no substitute for looking at the preview and adjusting accordingly. -
@Coises said in Select all marked text:
In quoting you, it appears that you meant your regular expression to be ^\d+/\d\t; but it didn’t come out that way, because the asterisks were interpreted as signaling italics and the backslash before the forward slash was dropped (which you may or may not have intended).
Right. This supposed to be
^\d+\/*\d*\t
. Thanks for an advice.