Open ProgerXP opened 4 years ago
Transform backslash
option is initially compatible with Regular expression search
mode:
void TransformBackslashes(char *pszInput, BOOL bRegEx, UINT cpEdit)
{
if (bRegEx)
UnSlashLowOctal(pszInput);
else
UnSlash(pszInput, cpEdit);
}
Where:
/**
* Convert C style \0oo into their indicated characters.
* This is used to get control characters into the regular expresion engine.
*/
unsigned int UnSlashLowOctal(char *s)
...
and:
/**
* Convert C style \a, \b, \f, \n, \r, \t, \v, \xhh and \uhhhh into their indicated characters.
*/
unsigned int UnSlash(char *s, UINT cpEdit)
...
Does it only enable
\0xx
transformation, not\n
, etc.?
Almost correct. The only change is that it works with octal escape sequence started with zero: \0oo
.
And yet without regexp mode
Transform backslashes
does not handle\0xx
?
Correct, in plain text search mode it supports only the following escapes sequences: \a, \b, \f, \n, \r, \t, \v, \xhh and \uhhhh
.
I tried to replace multiple line feeds with one using \n+
or specific \n\n
in the search field, but it always claimed the string was not found. Also tried combos of \r\n
and some \x
and \0
number sequences, all of which did not work no matter if "Regular expression search" or "Transform backslashes" was ticked.
Is this "regex" engine limited to a subset or is this some special flavour?
Is this "regex" engine limited to a subset or is this some special flavour?
Notepad2's regexp engine is indeed extremely limited but Notepad 2e is using Boost regexps which are fully featured PCRE. However, I believe regexps are matched against individual lines although I can't remember exact issue where this was discussed. On the other hand, Transform backslashes
is multi-line.
The easiest solution to your problem is Alt+R or Alt+Y command (Edit | Block | R
emove/Merge Blank Lines). Before doing that, I typically call Alt+W (Strip Trailing Blanks). Final document will have either no blank lines or will have at most 1 successive blank lines.
If you have a more complex pattern in mind then use Replace with Transform backslashes
enabled and Search String set to something like \n\n
. If you keep Replace With blank, doing so will remove blank lines just like Alt+R. However, if you set Replace With to \n\n\n
then you will convert blank lines to double blanks, something that shortcut commands like Alt+R cannot do.
Transform backslashes
recognizes these escape sequences: \a \b \f \n \r \t \v \xhh \uhhhh
.
Thanks, Merge Lines did help for the file(s) I'm currently working on. I need to dig into the many, many menu items :-) and the README in this Repo is massive :)
So the About box says "Notepad 2e", but I don't think this copy has a "fully featured PCRE" :-)
I can't get \n+
or \n*
to work for replace with Transform backslashes
or using anything more advanced such as grouping or limits \n{2,}\t
etc.
It would be nice to learn if search+replace are "global" or lines only; which would be limiting for several cleanup tasks I do on a regular basis. I need to fire up VSCode or other tools for this.
Just noticed "grep" and "ungrep" in the Search Dialog. What do they do? I'd use "real" grep if it wasn't so cryptic 😁 so pardon my ignorance; there's a reason I don't use vim or grep on the command line 😉
How can I get rid of this nuisance? The checkbox is grayed out.
I need to dig into the many, many menu items :-)
Menu exists for you to learn the hotkeys, not to use it all the time.
and the README in this Repo is massive :)
Better that then no help at all (erm, Notepad2).
I can't get
\n+
or\n*
to work for replace withTransform backslashes
or using anything more advanced such as grouping or limits\n{2,}\t
etc.
Transform backslashes
does not enable regexp mode so +
and others are literal. As for Regular expression search
, it cannot match across new lines - please read my comment again. If you need pattern matching across new lines (like \n(a|b)
) then Notepad2/e's regexps cannot help you (I barely had need for this in my experience). If you have fixed expression (\nab
) then Transform backslashes
will do the job.
NB: the fact regexp matching is single-line means you can't use \n
, etc. in Search String but they are perfectly fine in Replace With. For example, Replace Search String = $
, Replace With = \n
, Regexp mode to insert a blank line after every existing line. Use Search String = (?<=.)$
to insert blanks after non-blank lines. And so on.
Just noticed "grep" and "ungrep" in the Search Dialog. What do they do?
Grep leaves lines which the search expression matched at least once. Ungrep removes them.
How can I get rid of this nuisance? The checkbox is grayed out.
You have to create an INI file where Notepad2 will save your settings. Easiest way to do this is press F7, once per installation.
Menu exists for you to learn the hotkeys, not to use it all the time.
I would probably not click the menu all the time, but it's also to learn about the features in the first place and sorry, but I can't be bothered to memorize all the hotkeys for all the applications I use :-) If I use a feature a lot in a larger session I might memorize it, but I surely forget about it once a job is done.
And if a key combo is cumbersome to press in a specific workflow I might even ignore it before breaking my fingers, like this M$ "Ctrl+H" for Replace thing is always driving me nuts (also in VSCode) when it's Ctrl+R in other apps. Ctrl+R is also much easier to reach :)
Better that then no help at all (erm, Notepad2).
indeed :) Yet learning about features from a changelog isn't particulary productive from a UX point of view. Just saying, not complaining. 😇
I would probably not click the menu all the time, but it's also to learn about the features in the first place and sorry, but I can't be bothered to memorize all the hotkeys for all the applications I use :-)
Notepad2 is designed as an everyday tool like any other text editor or IDE. It's not like VS or MS Office, or Notepad++ for that matter have fewer shortcuts - or smaller menus. From this standpoint - yes, one quickly memorizes most hotkeys, even those not present in menus (which doubles as documentation much like comments in a properly written source code).
Ctrl+R is also much easier to reach :)
Not necessary, if you type with both hands. (Incidentally, Ctrl+R in Notepad2 stands for the same thing as Win+X, namely, Run.)
Yet learning about features from a changelog isn't particulary productive from a UX point of view.
Most certainly, but we are out of hands for writing user-friendly documentation. At least the README describes features added in Notepad 2e, which is a hairy lot.
Anyway, I hope your question(s) are resolved. If not, feel free to create new issues in the future.
which is a hairy lot.
exactly my point :)
and I don't favour shortcuts that require two hands to execute: that's not "short" ;-)
Have a nice time!
From a quick glance it seems that Find/Replace's
Transform backslashes
option is combinable withRegular expression search
in Notepad2. However, these checkboxes cannot be enabled simultaneously in 2e (#108).How exactly does
Transform backslashes
work together with regexp mode? Does it only enable\0xx
transformation, not\n
, etc.? And yet without regexp modeTransform backslashes
does not handle\0xx
?I want to document this because it sounds rather strange.