Brian Anderson wrote:
Hello,
I have a text with many quotations, that I want to change the case.
Currently the text of the quote is in all caps. I want to change it to
capitalize only the first letter of each word. The text I want to change
can be either a single word, multiple words on a single line, or
multiple words on multiple line, as follows:
WORD
MULTIPLE WORDS ALL ON THE SAME LINE
MANY WORDS
ON MANY
LINES
Thanks.
Brian
DISCLAIMER: all the following are untested.
make current word titlecase [Thus]:
guiw~
i.e.
gu make lowercase
iw inner word
(cursor is left on first letter of word)
~ change case
For all words of the current line (which will all be made titlecase [Like
This] regardless of current case).
guu:s/\<./\u\0/g
i.e.
guu make line lowercase
:s substitute current line
/ from
\< begin of word
. any single character
/ to
\u make next character uppercase
\0 all matched text
/ substitute flags are...
g everywhere in line
For all words one one of more visually highlighted lines
u:'<,'>s/\<./\u\0/g
i.e.
{Visual}u make selection lowercase and de-select
:'<,'> apply ex-command to latest visual area
the rest as above
Best regards,
Tony.