Input: "notepad++ capitalize every first letter of every word"
Output: "Notepad++ Capitalize Every First Letter Of Every Word"
I have been attempting to capitalize the first letter of every word using ctr+F
and regex
.
So far I have been attempting to use find:\b(.)
or \<(.)
with replace:\u\1
but this results in all of my letters being capitalized.
I have made due with ^(.)
& \u\1
followed by \s\b(.)
& \u\1
.
However, this seems silly to me as there are many posts talking about using the start of word boundaries. I am just having difficulty making them work. Thanks for your consideration!
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
Press Ctrl+M (Multirename Tool). In "Uppercase/Lowercase" dropdown select "First of each word uppercase".
You can also use Ctrl+Shift+U for UPPERCASE and Ctrl+U for lowercase if you like shortcut keys.
1. Capitals signal the start of a new sentence. This is a stable rule in our written language: Whenever you begin a sentence capitalize the first letter of the first word. This includes capitalizing the first word or a direct quotation when it's a full sentence, even if it appears within another sentence.
According to Notepad++ specification (see Substitutions section), there are three operators that can be useful when turning substrings uppercase:
\u
Causes next character to output in uppercase\U
Causes next characters to be output in uppercase, until a\E
is found.\E
Puts an end to forced case mode initiated by\L
or\U
.
Thus, you can either match a substring and turn its first character uppercase with \u
to capitalize it, or match a character and use \U
/\E
.
Note that Unicode characters won't be turned uppercase, only ASCII letters are affected.
Note that currently (in Notepad++ v.6.8.8) the beginning of word does not work for some reason. A common solution that works with most engines (use it in Sublime Text and it will match) does not work:
\b(\w)
This regex matches all word characters irrespective of their position in the string.
I logged a bug Word boundary issue with a generic subpattern next to it #1404.
The first solution can be using the \w+
and replace with \u$0
(no need using any capturing groups). Though this does not mean we only match the characters at the beginning of a word, the pattern will just match chunks of word characters ([a-zA-Z0-9_]
+ all Unicode letters/digits) and will turn the first character uppercase.
The second solution can be implemented with special boundaries defined with lookbehinds:
(?:(?<=^)|(?<=\W))\w
And replace with \U$0\E
.
The regex (?:(?<=^)|(?<=\W))\w
matches an alphanumeric only at the beginning of a line ((?<=^)
) or after a non-word character ((?<=\W)
).
The replacement - \U$0\E
- contains a \U
flag that starts turning letters uppercase and \E
is a flag that tells Notepad++ to stop converting case.
In case you have hyphenated words, like well-known
, and you only want the first part to be capitalized, you can use [\w-]+
with \u$0
replacement. It will also keep strings like -v
or --help
intact.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With