[comp.editors] vi problem

scottp@.bnr.ca (Scott Pace) (02/28/90)

The problem:
I want to pass the output of the :f command (which displays filename
and line # among other things) as an argument (or input) to a shell
script or program. For example, say I had a file called test which
contained the following:

echo "$1"

I want to be able to run the test script with the output from the :f
command as the argument $1 so that it might echo something like

""foo" [Not edited] [Modified] line 23 of 178 --12%--"

The entire purpose of this is so that I can pass down the current line
number and file name to a script.

Any suggestions would be much appreciated. Thanks.
--
Scott Pace, USUAL CUTE DISCLAIMER HERE
..uunet!bnrgate!scottp%bmerh461 or scottp@bmerh461.bnr.ca

maart@cs.vu.nl (Maarten Litmaath) (03/01/90)

In article <1608@bmers58.UUCP>,
	scottp@.bnr.ca (Scott Pace) writes:
)I want to pass the output of the :f command (which displays filename
)and line # among other things) as an argument (or input) to a shell
)script or program. [...]
)The entire purpose of this is so that I can pass down the current line
)number and file name to a script.

I don't think there's a direct way to give the current line number as an
argument to a script. :-(
The file name is `%', of course.
An indirect way to achieve what you want, is the following hack.
Example:

	map	q	:1,.w !(echo %; wc -l) > $HOME/tmp/vi.tmp^M:^A

	map!	^A	!echo `cat $HOME/tmp/vi.tmp`^M

Of course ^X stands for control-X.  Modify the `^A' map to meet your goals.
--
  "Belfast: a sentimental journey to the Dark Ages - Crusades & Witchburning
  - Europe's Lebanon - Book Now!" | maart@cs.vu.nl,  uunet!mcsun!botter!maart