bdewbank@ihlpb.ATT.COM (Ewbank) (09/10/88)
Hi Again -- Several people have provided corrections to my case conversion macro. In order that a correct version be available, I am reposting with the corrected version of the macros. They are: ---------------------------------------- map ^C : ^W -- reverse the case of the current word map ^C : ^T -- reverse the case of the current line. map ^C : a more elegant definition for ^T is map ^C : !!tr '[a-z][A-Z]' '[A-Z][a-z]'^M map ^C : but this trashes the screen display sometimes map ^T 0y$Pa^M^[-:s/./\~/g^M"0zy$dd@z map ^W lBi^M^[Ea^M^[-I ^[^d0^T-3J ---------------------------------------- Before :so'ing the above, convert the following characters: ^ C ==> <cntl> C [or these lines can be discarded] ^ M ==> <cntl> M ^ T ==> <cntl> T ^ W ==> <cntl> W ^ [ ==> <esc> NOTE: ^d **really** is a carat (^) followed by a lowercase d. The ^W macro will reverse the case of the current word (the word that contains the cursor). The ^T macro will reverse the case of the current line. Thanks to all of the people who sent me suggestions and bug reports. I hope that these two macros work better. The alternate definition of the ^T macro [using tr(1)] causes vi to get confused when the operation is done in the first line of a file that is less than about 20 lines long. The contents of the file is correctly translated, but the screen is corrupted with duplicate copies of the last few lines of the file. A detailed rundown of the operations of the macros is available on request. -- Bryan Ewbank, AT&T Bell Labs, bdewbank@ihlpb.ATT.COM === the opinions included herein are mine, not my employer's ===
evas@euraiv1.UUCP (Eelco van Asperen) (09/18/88)
Here's my macro to change the case of the current word; the one posted by Bryan Ewbank has the disadvantage that it substitutes a tab that may follow the word by a space. (This is done by the Join-command.) Beware: neither version works for single character words like 'a' ! map ^W lBi^M^[o^[-y$+P0Eax^[d$:s/./\~/g^M"zdd-@z--J Here's how it works; lB Go to the start of the word. The 'l' is done in case we're on the first letter of the word; just 'B' would move us back to the start of the previous word... i^M^[ Split line; word to convert is now at start of next line. o^[ Create an empty line below it. -y$+P Move up one line, yank its contents, go to empty line, and insert yank-buffer. 0Eax^[ Move to the start of the line, then to the end of the word and append an 'x'. This is necessary when the word to be converted is the last word on a line; otherwise, 'd$' would erase the last character of the word. d$ Delete remainder of line, starting at the 'x' we just added. :s/./\~/g^M substitute every character in the word by the '~' character. "zdd Delete line into buffer z. -@z Move up one line and use contents of buffer z as a Vi-command. '~' is the Vi-command to convert the case of a single character. --J Move back to original line and combine it with the modified part. -- Eelco van Asperen. uucp: evas@eurtrx / mcvax!eurtrx!evas #include <inews/filler.h> earn/bitnet: asperen@hroeur5 #include <stdjunk.h> "We'ld like to know a little bit about you for our files" - Mrs.Robinson, Simon & Garfunkel
edf@rocky2.rockefeller.edu (David MacKenzie) (09/24/88)
I noticed that several of the case-reversal postings contained comments stuffed behing dummy "^C" mappings. That's not necessary - vi allows you to include comments in .exrc files by starting them with the " (double quote) character; they run to the end of the line. ----- David MacKenzie Environmental Defense Fund edf@rocky2.rockefeller.edu (...rutgers!cmcl2!rocky2!edf)