Vi Quick Reference


	vi name		start vi editor with file   name   .
			The file is created if it doesn't exist.


	ZZ		exit from vi, saving changes.
	:q!		exit from vi, discarding changes.


	h		moves left one character position.
	j		moves down one line.
	k		moves up one line.
	l		moves right one character position.
	0	(zero)	moves to the beginning of a line.
	w		moves right one word.
	b		moves left one word.
	CTRL-u		moves up 1/2 screen full.
	CTRL-d		moves down 1/2 screen full.
	G		moves to the bottom of the file.
	nG		moves to line number   n   .
	CTRL-l		clear screen and re-draw.


	itextESC     inserts   text   to the left of the cursor.
		     Insert doesn't cause the cursor to move;
		     text appears as it is typed, terminate with
	atextESC     appends (inserts) text to the right of
		     the cursor, terminate with ESC.
	RtextESC     Replaces (overprints) characters at the 
		     cursor position, terminate with ESC.
	dd	     deletes the line the cursor is on.
	ndd	     deletes  n  lines from the cursor position.

	D	     deletes characters from the cursor position
                     to the end of the line.
	x	     deletes the character at the cursor.
	nx	     deletes n characters to the right of the
	u	     undo the last change.


	/pat/	     positions the cursor at the next 
		     occurrence of the string pattern.

	ESC	represents the ESC key.  Press the ESC key when 
                it is called for in the above commands.

	CTRL-	represents the CTRL key.  Hold the CTRL key and 
		press the following key simultaneously.


	}	move down one paragraph.
	{	move up one paragraph.
	mx	save the current cursor position and label it
		with the letter x. (x is any letter)
	'x	return to the cursor position labeled x.


	dw	delete the next word.
	.      (period) repeat last change.
	A	append at the end of the current line.
	P	put back deleted line(s).  Text deleted with D
		and dd commands may be pasted back with the P
		command.  Text is pasted in before the cursor
		From line number 'a' to line number 'b', 
		substitute the pattern 'old' with the pattern
		'new'.  You may use any text string which 
		doesn't contain a carriage return in place of 
		the 'old' and 'new' strings.  Use CTRL-G to tell
		what line the cursor is on.


	//	search for the next occurrence of a previously
		specified search string.  


	:w	write out current changes.  The vi editor works
		on a copy of your file.  The :w command causes
		the editor to write its copy over the original
		which is on the disk.
	:w name	write out changes to the file  name  .  This is
		like the :w command but the changes are written
		into the file you specify.  (good for making
		intermediate copies)
Cut and Paste	Move to the begining of the text to cut.  Use
		dd to delete (cut) several lines.  Use D to cut
		only the end of one line.  Move to the place
		where you wish to paste the text.  Use P to 
		put back the text. You may need to clean up
		the spacing after pasting.

Additional help is available in man vi.

UNIX Commands Directory File Other Help Search