Friday, November 11, 2011

Re: Overlapping shortcuts

On 11/11/11 13:23, George Papanikolaou wrote:
>> I understand that much, I'm just trying to figure out if
>> it's a native-Vim thing, or an add-on. My version of Vim
>> (stock build that comes with Debian Testing is 7.2.445, much
>> to Tony's chagrin) doesn't have a "gc" command.
>
> Actually yeah, it's not build in. But I found this (
> http://vim.wikia.com/wiki/Capitalize_words_and_regions_easily
> ) so I guessed... Anyway, Do you know any way of capitalizing
> a word??

Well, the mapping(s) you're using at the above URL can easily be
redone using something other than "gc" if you want:

nmap gCw guw~l
...

so you'd use "gC" to do your initial capitalization and leave
"gc" for tComment plugin.

As for ways to capitalize words, there are a number of ways that
correspond to your requirements and the above mappings take care
of most of them. However they're on a case-by-case basis. If
you have a bunch of them in the file and you can target them by a
pattern, you can do things like

:%s/\<\(.\)\(\w*\)/\u\1\L\2/g

which will do the entire file. It gets a little peculiar if you
have things like contractions, in which case you might want to
change "*" to "\+" to only touch things of 2+ characters long.
Adjust the regexps accordingly if you want to target things more
precisely.

-tim

PS: you'll want to Reply-All or Reply-List in your mailer so that
the mailing-list gets copied, in case you get me in over my head,
or Soeren Sonntag might be on list and add thoughts.


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: