> -----Original Message-----
> From: Bin Chen [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, March 08, 2007 9:44 PM
> To: vim@vim.org
> Subject: replace upper-case with lower-case
> 
> I want to replace below scheme within one command, that is 
> left the capitalization the same but replace the word.
> 
> SS->SS
> ss->ss


For all the people that responded on this thread, you may want to look at
this script which I think is great:

" KeepCase - Match mixed case while substituting /*{{{*/
" Author: Michael Geddes 
" http://www.vim.org/scripts/script.php?script_id=6
" Usage: Using KeepCase or KeepCaseSameLen defined here, do a substitution
"        like this:
" 
" %s/\u\<old_word\>/\=KeepCaseSameLen(submatch(0), 'new_word')/g
" 
" * KeepCase( original_word , new_word )  
"   returns the new word maintaining case
"   simply uses heuristics to work out some different common situations
"     given   NewWord
"     Word   --> Newword
"     WORD    --> NEWWORD
"     word    --> newword
"     WoRd    --> NewWord
"     woRd    --> newWord


HTH,
Dave


Reply via email to