Path: utzoo!utgpu!watserv1!watmath!att!occrsh!uokmax!munnari.oz.au!samsung!usc!snorkelwacker!bloom-beacon!eru!hagbard!sunic!mcsun!cernvax!chx400!ethz!neptune!inf.ethz.ch!wyle From: wyle@inf.ethz.ch (Mitchell Wyle) Newsgroups: comp.editors Subject: Re: vi question Summary: flame people who help you Keywords: change case Message-ID: <7669@neptune.inf.ethz.ch> Date: 12 Sep 90 09:36:32 GMT References: <2112@bnlux0.bnl.gov> Sender: news@neptune.inf.ethz.ch Reply-To: wyle@inf.ethz.ch.inf.ethz.ch (Mitchell Wyle) Organization: Departement Informatik, ETH, Zurich Lines: 59 In <2112@bnlux0.bnl.gov> como@max.bnl.gov (Andrew T. Como) asked: >Is there a way to change a word case....(ie...from lower to upper) I answered his query with an incorrect response. He flamed me for trying to help him. My response to his flame (below) contains a correct solution to his problem. It has different tradeoffs from other posted replies. It does not assume the tilde function; it does not clobber &. It does create a temporary line after the current paragraph, which the cause your cursor to jump around. Here is my solution and my reply to Mr. Como's flame. I don't usually flame people trying to give me help, but I guess my kind should be banned -oops- band from the matrix... 8-O >The question was "how to change a word case" your answer >rtfm? (read the fine manual) > ^^^^ >:%s/[a-z]/\u/g > >is unitelligible and ineffective. Thanks for showing me your The last line was a vi command for changing the case of all letters; to apply it only to a word, one can (according to the manual) use a sequence of vi keystrokes such as: madw}p0:s/./\u&/g^V^Mdw`ahp where the ^V is a control V and ^M is a control M You can then map this keystroke sequence to a more convenient one as in map ;cw madw}p0:s/./\u&/g^V^Mdw`ahp and put that line in your EXINIT or ~/.exrc The macro marks the current position (at the begining of the word whose case you want to change) with marker a. deletes the word into the delete buffer, puts it a paragraph lower, changes its case, and puts the upper-case word back. If you are running on a slow terminal, you can watch each step. I expect there are more elegant solutions; this one works for me, though. >intelligence. Its people like you that should be band from the >network because of your attitude I don't normally reply to flames, especially from people whom I was trying to help. Thanks for posing an interesting vi problem, though. I might add it's solution to my vi book. Thanks also for the flame; it goes into my collection. Yours is mild compared to some of them in German. German is a better language for flaming. -Mitch