On 14/07/06, Marshall Abrams <[EMAIL PROTECTED]> wrote:
I just asked the same question recently. The following email includes all of the recent discussion:From: [EMAIL PROTECTED] Subject: Re: auto upper/lower in replace pattern based on search pattern? Date: July 13, 2006 1:19:24 PM EDT To: [email protected] Thanks--keepcase.vim is great. So now with :%s/firstname/\=KeepCase(submatch(0), 'LastName')/ig I can replace all instances of firstname with lastname firstName with lastName FirstName with LastName But \=KeepCase(submatch(0), '') is a mouthful. Not a problem; that exact expression does what I'll want 99% of the time, so I've already mapped it to a control-key. And there are other ways to abbreviate. Still, this seems *such* a useful function in a programmer's editor, it seems worthwhile to build it into the :substitute command as some kind of optional behavior. How about one of these: :s/firstname/LastName/k ['k' for keepcase] :set MaGiC or some kind of delimiter that can be stuck into a pattern to say "use KeepCase() on this part". OK, I know there aren't many delimiters that are available at this point.
Thanks Marshall! Yes, I too was looking for a script-less approach, something built-in. I'll probably end up using keepcase.vim that Yakov helpfully pointed out, but it just seems odd for this not to be a built-in functionality. Surely this is a commonly occuring problem: s/foo/bar/g , where - in regular text, foo may sometimes appear at beginning of sentences, capitalized - in source code, appearing as FOO (#define), foo (regular variable), MyFoo (class name in camelcase)) I constantly run into this problem when refactoring code, when choosing more appropriate and descriptive names for concepts and classes. Initially, when I started looking for this feature, I totally expected to see it as a flag to :s. It's the most obvious place for such a feature, IMHO. Hence I totally agree with, and would like to add my voice/vote to yours, on your proposed "k" flag. :)
