vi Editor Commands



 Beginning Your edit Session 

	Edit file				vi [file]
	Recover edit session			vi -r [file]

 Controlling Your Screen Display 

	Eliminate @ lines			"CTRL/R"
	Repaint current screen			"CTRL/L"

 Moving the Cursor 

	Beginning of current line		O or ^
	Beginning of first screen line		H or [[
	Beginning of last screen line		L or ]]
	Beginning of middle screen line		M
	Down one line				j, "Return", +
	End of current line			$
	Left one character			h, "CTRL/H"
	Left to beginning of word		b or B
	Right one character			l, "Space"
	Right to end of word			e, E
	Right to beginning of word		w or W
	Up one line				k or -
	Beginning of next sentence		)
	Beginning of previous sentence		(


 Paging Through Text 

	Back one screen				"CTRL/B"
	Down half screen			"CTRL/D"
	Forward one screen			"CTRL/F"
	Forward to end of file			G
	Move cursor to specified line*		 line no. G
	Up half screen				"CTRL/U"

 Searching Through Text 

	Backward for pattern			?pattern
	Forward for pattern			/pattern
	Repeat pattern serach			n
	Reverse direction of search		N

 Searching Through Text 

	Append text after cursor		a
	Append text after end of line		A
	Insert text before cursor		i
	Insert text at beginning of line	I
	Open new line after current line	o
	Open new line before current line	O
	Take next char literally & display      "CTRL/W"

 Modifying Text 

	Change current word			cw or cW
	Change current line (cursor to end)	C
	Delete character (cursor forward)*	x
	Delete character (before cursor)*	X
	Delete word*				dw or dW
	Delete line*				dd
	Delete text to end of line		D
	Duplicate text				(use yank and put)
	Join current line with next line*	J
	Move text				(use delete and put)
	Put buffer text after/below cursor	p
	Put buffer text before/above cursor	P
	Repeat last modification command	.
	Replace current character*		r
	Replace text to end of line		R
	Substitute text for character*		s
	Undo your previous command 		u
	Transpose characters			xp
	Yank(copy) word to buffer*		yw
	Yank(copy) current line to buffer*	Y

 Making Corrections During Text Insertions
	
	Overwrite last character		"DELETE"
	Overwirte last word			"CTRL/W"

 Making Corrections During Text Insertions

	Quit (no changes made)			:q!
	Quit and save changes			ZZ or :wq!
	Quit and discard changes		:q!

 Using Alternate ex Commands

	Copy specified lines+			:co or t
	Display number of each text line	:set nu
	Move lines after specified line+	:m
	Read file in after specified line+	:r file
	Review current editor options		:set
	Review editor options			:set all
	Set new editor option			:set option
	Write changes to original file+		:w
	Write changes to specified file+	:w file
	Write (overwirtes) to existing file+	:w! file



* May be preceded by a number to indicate characters, words, lines.
  For example, the command 3dw deletes the next three words.

+ May be preceded by a line number or line range (comma-separated)
  to indicate a line other than the current line or to affect multiple lines.
  For example, the command 10,15m80 moves lines 10-15 after line 80.