[olug] Unix Tip: VI EXECUTION

thehaas at binary.net thehaas at binary.net
Tue Apr 29 01:24:26 UTC 2003


On Mon, Apr 28, 2003 at 01:39:44PM -0700, Unix Guru Universe wrote:
> To increase your productivity, 
> it would be a lot quicker if you 
> could execute these commands 
> from within the editor and view 
> their output before writing them 
> to your script.
> 
> This is possible and quite 
> straight forward.  Enter the 
> following within vi
> 
> :!testscript
> 
> (i.e. colon exclamation mark)
> 
> Then enter your command as you 
> would at the $ or # prompt.  
> 
> The command executes, the result 
> is displayed and you are propmted 
> to press return to continue.
> 

Of course, if "." is not in your path, this won't work.

Another handy trick is to put the output of a command into the file you
are editing:

:r!command

I use this at least twice a day.




More information about the OLUG mailing list