Gene Kwiecinski wrote:

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
(snip)

'&' is the matched pattern.  "\L&" will take the matched pattern and
lcase it all, then "\u&" will just ucase the initial letter of a word.
So each respective pass will be

        WORDS TO INITCAP                originally
        words to initcap                after lcasing it all
        Words To Initcap                after the initcap

Someone here might have a more elegant way of doing it, but I've done it
this way in the past for so long it's practically a macro to me.

Fwiw:

        \L      lcase everything
        \l      lcase initial letter of each word
        \U      ucase everything
        \u      ucase initial letter of each word

What I use:

vno  <silent> <Leader>ft   :B s/\<\(\S\)\(\S*\)\>/\u\1\L\2\E/g<cr>

This is a vmap, so use it with visual mode (V, v, or ctrl-v). Plus, it uses my :B command, which restricts substitutes to just the visually highlighted region. That map is available as part of vis.vim, itself available at:

   http://mysite.verizon.net/astronaut/vim/index.html#VIS

or a more stable version from:

   http://vim.sourceforge.net/scripts/script.php?script_id=1195

Regards,
Chip Campbell


Reply via email to