Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.editors Subject: Re: VI and parameter substitution in macros Message-ID: <7334@star.cs.vu.nl> Date: 17 Aug 90 14:35:06 GMT References: <2158@tnoibbc.UUCP> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 51 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)