larry@tessi.uucp (Larry Gillespie) (12/15/90)
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. -Larry Gillespie Test Systems Strategies, Inc., 8205 SW Creekside Pl., Beaverton, Ore. 97005 (503) 643-9281 tessi!larry@uunet.UU.NET
tchrist@convex.COM (Tom Christiansen) (12/16/90)
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
lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) (12/17/90)
In article <622@tessi.UUCP> larry@tessi.uucp (Larry Gillespie) writes: >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. Here are three macros I use to upper case, lower case and capitalize words (they have been run through 'cat -v'). Unfortunately, they don't take an argument. " Lower case word. map ^[l :set noai^Mbi^M^[ea^M^[k:s/.*/\L&/^Mk$:j!2^M:set ai^M " Upper case word. map ^[u :set noai^Mbi^M^[ea^M^[k:s/.*/\U&/^Mk$:j!2^M:set ai^M " Capitalize current word. map ^[c :set noai^Mbi^M^[ea^M^[k:s/.*/\L&/^M~k$:j!2^M:set ai^M > >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. Here is a macro to change the case of a word. It too doesn't take an argument. I should note that all of these macros work on the word the cursor is on, with the assumption that the cursor isn't on the first character of the word. If the latter assumpton isn't satisfied, they work on the preceding word. " Change case of word. map ^[k :set noai^Mbi^M^[ea^M^M^[2k!}tr '[a-zA-Z]' '[A-Za-z]'^Mjdd2k$:j!2^M:set ai^M > >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. > > >-Larry Gillespie >Test Systems Strategies, Inc., 8205 SW Creekside Pl., Beaverton, Ore. 97005 >(503) 643-9281 >tessi!larry@uunet.UU.NET -- Mike Lijewski (H)607/272-0238 (W)607/254-8686 Cornell National Supercomputer Facility ARPA: lijewski@theory.tn.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 25 Renwick Heights Road, Ithaca, NY 14850
gwc@root.co.uk (Geoff Clare) (12/18/90)
In <111467@convex.convex.com> tchrist@convex.COM (Tom Christiansen) writes: >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). > map v ywmno^[P:s/./\~/g^M0"nDdd`n@n > map V yWmno^[P:s/./\~/g^M0"nDdd`n@n Or if your version of vi doesn't understand "\~" (most don't) you can replace :s/./\~/g^M with :s/\([^a-zA-Z]*\)\([a-z]*\)\([A-Z]*\)/\1\U\2\L\3/g^M I have this as a separate macro for changing case over a whole line, and call it within the "word" and "Word" macros. One warning: if you have "showmatch" set, then when vi displays the command it will pause three times. I got so annoyed by this I have stopped using "showmatch" and just use the '%' command when I want to check bracket matching. (I prefer this method now, anyway). On a related note, does anyone know if POSIX.2a has adopted the current behaviour of "~", or have POSIX done the decent thing and invented a proper "exchange case" command? Since "v" is currently unused that would be a good choice. It would be great to be able to use "vw" to change case of a word, "vt." to change case up to a "." character, "vv" to change a whole line, etc. Whoever originally implemented "~" as such a horrible botch instead of making it work like "d", "y", and "c" should be shot! -- Geoff Clare <gwc@root.co.uk> (Dumb American mailers: ...!uunet!root.co.uk!gwc) UniSoft Limited, London, England. Tel: +44 71 315 6600 Fax: +44 71 315 6622 (From 22nd December 1990, Tel: +44 71 729 3773 Fax: +44 71 729 3273)
QQ11@LIVERPOOL.AC.UK (Alan Thew) (12/19/90)
Since ~ can be used with a count, does anyone know why SunOS will not let the count be greater than 64? Thanks. Alan Thew : University of Liverpool Computer Laboratory Bitnet/Earn: QQ11@LIVERPOOL.AC.UK or QQ11%UK.AC.LIVERPOOL @ UKACRL UUCP : ....!mcsun!ukc!liv!qq11 Voice : +44 51 794 3735 FAX : +44 51 794 3759 Internet : QQ11@LIVERPOOL.AC.UK or QQ11%LIVERPOOL.AC.UK @ NSFNET-RELAY.AC.UK
asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) (12/27/90)
In article <90353.110944QQ11@LIVERPOOL.AC.UK> QQ11@LIVERPOOL.AC.UK (Alan Thew) writes: > Since ~ can be used with a count, does anyone know why SunOS will not > let the count be greater than 64? > > Thanks. The vi editor on DEC Ultrix systems does not take a count. Pity. -- asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) ========================= Opinions are Mine, Typos belong to /usr/ucb/vi "We're sorry, but the reality you have dialed is no longer in service. Please check the value of pi, or see your SysOp for assistance." UUCP: hplabs!felix!asylvain ============================================
kirkenda@eecs.cs.pdx.edu (Steve Kirkendall) (01/02/91)
In article <2567@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes: > >On a related note, does anyone know if POSIX.2a has adopted the current >behaviour of "~", or have POSIX done the decent thing and invented a >proper "exchange case" command? Since "v" is currently unused that >would be a good choice. It would be great to be able to use "vw" to >change case of a word, "vt." to change case up to a "." character, >"vv" to change a whole line, etc. > >Whoever originally implemented "~" as such a horrible botch instead of >making it work like "d", "y", and "c" should be shot! I'd vote for accepting STEVIE's "tildeop" option as a standard. By default, STEVIE uses ~ in the standard way, but after you do a ":set tildeop", the ~ command becomes an operator like the c/d/y/</>/! commands. Or maybe we want a variety of capitalization commands: one to flip cases, one to make uppercase, one to make lowercase, one to capitalize text using the conventions for titles... What do you bet EMACS already has this? :-) New subject: In the next version of Elvis, the "v" key will be used to visibly mark one some text for one of the operator commands. You press "v" and the character that the cursor's on will be hilighted. As you move the cursor around, the hilighted area stretches to include all characters between the original position and the current cursor position. When you hit one of the operator keys, the operator is *immediately* applied to the hilighted text. The "Shift-V" key will do the same thing, but it will act on whole lines instead of characters. ------------------------------------------------------------------------------- Steve Kirkendall kirkenda@cs.pdx.edu Grad student at Portland State U.
les@chinet.chi.il.us (Leslie Mikesell) (01/04/91)
In article <1021@pdxgate.UUCP> kirkenda@eecs.UUCP (Steve Kirkendall) writes: >New subject: >In the next version of Elvis, the "v" key will be used to visibly mark one >some text for one of the operator commands. You press "v" and the character >that the cursor's on will be hilighted. As you move the cursor around, the >hilighted area stretches to include all characters between the original >position and the current cursor position. When you hit one of the operator >keys, the operator is *immediately* applied to the hilighted text. >The "Shift-V" key will do the same thing, but it will act on whole lines >instead of characters. There is a philosophical problem to solve first. Suppose the last line of the rectangle you want to select does not extent to the width you want to include. Will "marking-mode" automatically allow the cursor to move beyond the end of the text on a line? Then, given the ability to select arbitrary rectangles, you will want to use it more or less arbitrarily. That is, you should be able to delete, move, or copy the chunk, with the destination of the move or copy allowed to be specified as character or line mode regardless of the mode of the selection (i.e insert a column into existing text or make the column into new lines). Also, it should be possible to use the selected area as an ex mode range specifier (%v already seems to be used, though). Les Mikesell les@chinet.chi.il.us
steveha@microsoft.UUCP (Steve Hastings) (01/08/91)
In article <2567@root44.co.uk> gwc@root.co.uk (Geoff Clare) writes: >On a related note, does anyone know if POSIX.2a has adopted the current >behaviour of "~", or have POSIX done the decent thing and invented a >proper "exchange case" command? Since "v" is currently unused that >would be a good choice. It would be great to be able to use "vw" to >change case of a word, "vt." to change case up to a "." character, >"vv" to change a whole line, etc. I vote for the following as true operators: 'v' to lowercase, 'V' to uppercase, and '~' to change case. So "VV" would uppercase a line, etc. Since many people expect the current, weird behavior of '~', maybe the "se tildeop" switch to enable/disable the feature would be a Good Thing to adopt. -- Steve "I don't speak for Microsoft" Hastings ===^=== ::::: uunet!microsoft!steveha steveha@microsoft.uucp ` \\==|