[Eug-lug] how do I get out of this?

horst horsu at freeshell.org
Thu Nov 15 19:46:10 PST 2007


> Date: Thu, 15 Nov 2007 12:06:43 -0800
> From: Mike Cherba <mike.cherba at caviumnetworks.com>
> 
> Interestingly enough, ! by itself on a line in vi doesn't have the
> effect of a "force" command.  It is a very different option.
> !! <command>
> executes <command> and replaces the line the cursor is on with the
> output.  so "!!ls"  gives you the output of ls added into your file.

Actually, it goes even further: You can even feed part of the file you are 
editing to a shell command, let the command do its work, and insert the 
output back into the file.
  Quoting from   http://www.eng.hawaii.edu/Tutor/vi.html
  For example, "!4jsort" will take five lines from the current cursor 
position and execute sort.

A bit of a mind twister (and actually new to me). So I tried
  !22jgrep -v someTerm
vi reported: "12 fewer lines"  (those 12 out of 23 that matched someTerm)
  ((of course, there are other ways to remove those 12 matching lines in vi))

Interesting how far we drifted from the original 'lone !' ...

Mike, thanks for the links to other vi tips/documentations......Horst





More information about the EUGLUG mailing list