Quick references

George Toft plug-discuss@lists.plug.phoenix.az.us
Fri, 14 Jun 2002 21:27:18 -0400


You missed two commands I use A LOT: C (whack off the line and insert)
and ^G (WTF am I?)

When is page two coming out which shows the : commands, like search &
replace, block copy, block move, etc?

Then you need the Palm Pilot note version.  I have one that was very
popular at the last Unix shop I was at.

Here's my Palm version:
vi Tips

- Search and replace:
:<startline>,<endline>s/<search text>/<repl text>/g
:s/this/that/g

- Moving text:
:<startline>,<endline>m<new location>
:1,2m5

- Copying text:
:<startline>,<endline>co<new location>
:1,2co5

- Delete line that contains "string" 
:<startline>,<endline>g/string/d

- Delete line that does not contain "string" 
:<startline>,<endline>v/string/d

Ranges:
$ = last line
. = current line
___________________
Cursor Movement
G = end of file
$ = end of line

Interact with Unix
- Execute the command "pwd" on unix and return to vi 
:!pwd
- Execute the command "pwd" on unix and capture the output into the file
being edited 
!!pwd
- Exit out of the file being edited into unix temporarily 
:sh 

Read / Write from another file
- Write lines 1 through 10 from the current file to outfile  
:1,10 w outfile
- Write lines 1 through 10 from the current file to outfile forcefully 
:1,10 w! outfile
- Append lines 1 through 10 from the current file to outfile 
:1,10 w >> outfile
- Read from infile to the current file below current line
:r infile
- Read from infile to the current file below line 23 of current file
:23r infile

Misc
- Set line numbers to visible
:set num


George


William Lindley wrote:
> 
> I put this together for vi --
> 
>    http://www.wlindley.com/gnu/vi.htm
> 
> ________________________________________________
> See http://PLUG.phoenix.az.us/navigator-mail.shtml if your mail doesn't post to the list quickly and you use Netscape to write mail.
> 
> PLUG-discuss mailing list  -  PLUG-discuss@lists.plug.phoenix.az.us
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss