Selecting things of a certain type
-
Hi, I was wondering whether I could select things that the application sees as separate things. I’m very new to Notepad++. I was editing a minecraft language file and I want an easy way to select all the strings so I can change them to uppercase all at once. Please help. Thanks!
Here’s the file I was working on: -
Your use of the phrases “certain type” or “separate things” is rather ambiguous.
If you have a selection in Notepad++, then Edit > Convert Case To… > UPPERCASE (or the
Ctrl+Shift+U
default keyboard shortcut) will convert the active selection to all-caps.For manually selecting multiple pieces of text at the same time, Settings > Preferences > Editing > ☑ Enable Multi-Editing will allow you to use Ctrl+Click (and drag) to select multiple pieces of text at the same time.
Or, if you have a search expression (in Regular Expression mode) that can find all the text that you want to uppercase, if your Find What already finds the right text, then Replace With can be set to
\U$0
to replace the found text with the uppercase version of the text.But without more detail than you gave, I can only give this hints.
----
(The links above were taken from various sections of the Online User Manual)
Useful References
-
Find/replace
(?-si)(?::\s*"|(?<!%)%\d*[dsf]|(?!\A)\G)\K((?:(?!(?:(?<!%)%\d*[dsf]|")).)*)
with\U\1\E
.Note that this won’t actually convert all your text to upper-case, because some of it (the
%s
format specifiers) will probably cause bugs downstream if it is capitalized. This regex is very careful to avoid capitalizing format specifiers, which is a lot of why it looks (and is, TBH) so hairy.My regex doesn’t handle all the possible syntax surrounding format specifiers, because I don’t have 3 hours to spend enumerating and debugging each weird edge case, but it should be fine assuming that all the strings are values in dictionaries. The find-regex becomes the absolutely abhorrent
(?-si)(?:"|(?<!%)%\d*[dsf]|(?!\A)\G)\K(?=[^"]*"\s*[,\]\}])((?:(?!(?:(?<!%)%\d*[dsf]|")).)*)
in the case where the strings can be strings in arrays or values in dictionaries.Test text:
{ "a.b": "caps %02d %5s %d %03fnocaps %%02dcaps", "b.c.d": "%%caps %3sap %s cap" }
Expected output:
{ "a.b": "CAPS %02d %5s %d %03fNOCAPS %%02DCAPS", "B.C.D": "%%CAPS %3sAP %s CAP" }
If you’re absolutely sure you want to capitalize everything that’s not a key, just use this much simpler regex-replace:
"\s*:\s*"[^"]*"