Christian Brabandt <[email protected]> [09-11-22 16:36]: > > Hi meino.cramer! > > On Sa, 21 Nov 2009, [email protected] wrote: > > > In my file I have (for example) the following words > > > > Uppercase > > uppercase > > UPPERCASE > > > > Doing a > > > > :s/uppercase/frankenstein/g > > > > produces > > > > frankenstein > > frankenstein > > frankenstein > > > > Really simple and stupidly written down function: > fu! SmartReplace(old, new) > let r='' > let i=0 > for char in split(a:old, '\zs') > if i>strlen(a:new) > return r > endif > if char2nr(char) > 64 && char2nr(char) < 91 > let r.=toupper(a:new[i]) > else > let r.=a:new[i] > endif > let i+=1 > endfor > if i < strlen(a:new) > let r.=a:new[i :] > endif > return r > endfu > > Then doing > :%s/uppercase/\=SmartReplace(submatch(0), "frankenstein")/ > on > > "uppercase > "Uppercase > "UPPERCASE > > yields: > "frankenstein > "Frankenstein > "FRANKENSTein > > Is that what you want? > > > > Mit freundlichen Grüßen > Christian > -- > Die Realität ist eine Illusion, die durch > einen Mangel an Whisky hervorgerufen wird. > -- Schottisches Sprichwort > > >
-- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. Hi christian.brandt Oh yeah! This evening all scripts ever existing in time and space seem to unit in my mailbox, hahaha ! :) Thanks a lot, Christian...I will test it! Have a nice sunday! Best regards, mcc --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
