The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 07-04-2008
sjdolding sjdolding is offline
Registered User
  
 

Join Date: Jul 2008
Location: UK
Posts: 2
Return shell value to a VI macro

Hi,

Have searched around for a solution to this and get frustrating close but have not nailed it.

vi on HP-UX

what I'm trying to do is utilise the key mapping available within Vi to run a shell script which uses awk script to scan the file i'm working on and return the line number or unique pattern (could go either way but the principle im trying to achieve is pass a value back so that vi macro can then utilise it)

The closest ive got via Google is

The most powerful macros, however, are created using programs combined
into shell scripts (or DOS batch files), and acting as filters on the text
sent to them from within vi. Such shell scripts or programs must take standard
input and send results to standard output (which most UNIX tools do).

but guess what no example! I've tried more in hope than expectation to set a map command as follows:

map ^[[O ^[: !line_test^M

where line_test is hard coded to echo out a line number which then can but as expected all it does is echo out the line number and is not interpreted as the line number I wanted to go to.

I subsequently modified the script to exit with a value and then tried to use $?

map ^[[O :!line_test : ^[: $?^M

but get error badly formatted address

any help greatly appreciated.