Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!sun-barr!newstop!texsun!vector!egsner!mic!convex!convex.COM From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.editors Subject: Re: Okay, now, how to you change case of a *word* in vi? Message-ID: <111467@convex.convex.com> Date: 16 Dec 90 06:04:14 GMT References: <622@tessi.UUCP> Sender: news@convex.com Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 41 From the keyboard of larry@tessi.uucp (Larry Gillespie): :After seeing people discussing how to change an entire file, or a line, :to upper or lower case, I'd like to ask a harder one. For years, I've :tried to figure out a way to change the case of just a single word :(or, optionally, 'W'ord), and, extrapolating, a number of words (using :a range specification). A friend of mine figured out a most ineligant :way of doing a single word, but it's not acceptable, because the display :does lots of ugly things while it's working. And, it can't take an :argument. : :Further, I also want a real hard one. I want to be able to :switch the case of what is found there, not just up-case or low-case :everything. I guess what I'd like is for '~' to be able to take a :range argument. :That not being the case, have you or anybody you know got the wizardry :to to that (hopefully elegantly)? I am the humble admirer of the one :with the answers to these questions that I pose. (I don't suppose a !perl solution is acceptable? :-) " uses both register n and mark n map v ywmno^[P:s/./\~/g^M0"nDdd`n@n map V yWmno^[P:s/./\~/g^M0"nDdd`n@n I'm not sure what you consider elegant, but this does seem to fit all your criteria. The display only does one thing while it's working, it's not too ugly, and if you blink, you'll miss it. :-) The 'v' version is for 'w' type words, the 'V' for 'W' type ones. Furthermore, it even accepts on numeric count, so '3v' will toggle the case on the next three words, and '2V' will do so for the next two Words. The one proviso is that these multiple words must all lie on the same line. --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "With a kernel dive, all things are possible, but it sure makes it hard to look at yourself in the mirror the next morning." -me