Select all 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.