Blank Trim operations, on a text selection, ONLY
guy038 last edited by guy038
Hello Noitidart and All,
Noitidart, I reply to your last post, on Github N++ forums, at the address :
As I said before, the N++ Blank Trim Operations, logically, work on the totality of the current file. Luckily, it’s easy enough to use a search/replacement, in regular expression mode, to get rid of these blank characters, in a normal selection, ONLY.
And, of course, you can store this specific search-replacement in a macro, which can be, easily, executed, further, from the macro Menu OR by hitting its associated shortcut !
Let’s suppose you would like a macro to delete all trailing blanks in a selection. To do so :
Open any text file
First, select some lines ( even without any trailing blank )
Select the menu option Macro - Start recording OR the red circle button, on the Toolbar
Open the Replace dialog ( CTRL + H )
In the Find what zone, type
Leave the Replace with zone empty
Check the In selection option
Select the Regular expression search mode
Click on the Replace All button
Select the menu option Macro - Stop Recording Or the black square button, on the Toolbar
Open the menu option Macro - Save Currend recorded Macro…
Type, for instance, Trim SELECTION trailing BLANK characters as the current name for this macro
Choose a shortcut for this macro ( Take care NOT to use an existing Notepad++ or plugin shortcut ! )
Click on the OK button, to valid your choices
Now, each time you select a normal selection ( neither rectangular selection, nor multiple selections ), any trailing blank character will be removed of that selection, as soon as you choose the menu option Macro - Trim SELECTION trailing BLANK characters OR you use the its specific shorcut
Without any previous normal selection, this macro doesn’t do anything. Nice isn’t it ?
Noitidart last edited by Noitidart
Oh wow I didn’t know we could save things as a macro! Thanks very very much for this detailed instructions Im going to follow it right away!
And this new community is absolutely beautiful! Is it public software or custom?
edit: just tested it and it works so awesome! thank you!
btw what language uses
\hi can’t find that symbol in any regex tutorials, what is it btw?
guy038 last edited by
I think that this N++ community is based on NodeBB forums. You’ll get further information, from the link below :
See also the Don Ho post :
Secondly, you’ll find good documentation, about the new Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by Notepad++, since its
6.0version, at the TWO addresses below :
The FIRST link explains the syntax, of regular expressions, in the SEARCH part
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part
As for the \h regex syntax, just have a look to the paragraph “Single character” character classes, in the SEARCH document !
Noitidart last edited by
Thanks @guy038 for all that info this is real cool!
Scott Sumner last edited by
each time you select a normal selection ( neither rectangular selection, nor multiple selections )
Without any previous normal selection, this macro doesn’t do anything
I recently had a need to record a replace macro that operated only upon selected text. What I found was different from what @guy038 reported about multiple selections. I found that if multiple selections are active when the macro is invoked, it WILL perform the replacement, but only in the selection created most recently (this is consistent with how Notepad++ performs this replacement interactively).
taa1 last edited by
\h+$removes trailing spaces, what regex would remove leading and trailing spaces? I’m looking for the equivalent of Edit -> Blank Operations -> Trim Leading and Trailing Space, but on selected text only.
Scott Sumner last edited by
Find what zone:
Replace with zone:
In selection checkbox: ticked
Action: Press Replace All button