avb@tnoibbc.UUCP (Andre van Brussel) (08/17/90)
I have a question of using macros with parameter substitution : E.G. I often use the command : :%g/STRING/d The only thing that changes is the string.If I map this for instance under the # key , I would give the command : # hello, and the macro is invoked as : :%g/hello/d. The next time I invoke it with : # yes, the command would be : %g/yes/d. Is this possible in Vi, and HOW ?? - +---------+------------------+----------------------------------+ | Andre | TNO - IBBC | INTERNET => avb@tnoibbc | | van | PO-box 49 | DOMAIN => avb@ibbc.tno.nl | | Brussel | 2600 AA Delft | FAX => +31 15 843990 | | | the Netherlands | VOICE => +31 15 842019 | +---------+------------------+----------------------------------+
maart@cs.vu.nl (Maarten Litmaath) (08/17/90)
In article <2158@tnoibbc.UUCP>, avb@tnoibbc.UUCP (Andre van Brussel) writes: ) )I have a question of using macros with parameter substitution : ) )E.G. I often use the command : ) ):%g/STRING/d ) )The only thing that changes is the string.If I map )this for instance under the # key , I would give )the command : # hello, and the macro is invoked as : ):%g/hello/d. The next time I invoke it with : # yes, the )command would be : %g/yes/d. Here's a part of an article I've posted before. --------------------cut here-------------------- )... ) Is there any way to search for a word which is the result of a shell ) script? ( something like /!script , where script contains something like ) echo "xxxxxx" ) :map * :r!do-command^V^Mi/^V^["qdd@q^L ...where `do-command' is: #!/bin/sh # do-command: read a command and execute it awk 'END { printf("\t\t\t\rCommand: "); }' < /dev/null > /dev/tty read cmd && eval "$cmd" --------------------cut here-------------------- In your case the map would be something like: :map * :r!read_and_echo^V^Mi:%g/^V^[A/d^V^["qdd@q^L ...where `read_and_echo' is: #!/bin/sh # read_and_echo: read a string and echo it awk 'END { printf("\t\t\t\rString: "); }' < /dev/null > /dev/tty read cmd && echo "$cmd" You might want to change the `\t\t\t' sequence to an appropriate number of spaces. -- "UNIX was never designed to keep people from doing stupid things, because that policy would also keep them from doing clever things." (Doug Gwyn)