Vi - Quick Reference - UniX
Vi - Quick Reference - UniX
Vi - Quick Reference - UniX
I, a I, A O, O
Insert text before, after cursor. Insert text before beginning, after end of line. Open new line for text below, above cursor. Replace character. Change word. Change current line. Change to end of line. Type over (overwrite) characters. Substitute: delete character and insert new text. Substitute: delete current line and insert new text. Delete character under cursor. Delete character before cursor. Delete word. Delete current line. Delete to end of line. Yank (copy) word. Yank current line. Put yanked text after, before cursor. Repeat last edit command. Undo last edit; restore current line. Join two lines.
Change
R cw cc C R S S
Delete, move
X X dw dd D
Yank
yw yy P, P
Other commands
. U, U J
Searches
/pattern
?pattern N, N /, ?
Search backward for pattern. Repeat last search in same, opposite direction. Repeat previous search forward, backward.
Line number
[CTRL-G] nG G :n
Display current line number. Move to line number n. Move to last line in file. Move to line n in file.
Command
ZZ :x :wq :w :w! :q Q :e file2 :n :e! :e # :vi :
Function Write (save) the file if modified, and quit file. Write (save) the file if modified, and quit file. Write (save) the file unconditionally, and quit file. Write (save) file. Write (save) file, overriding protection. Quit file. Quit vi and invoke ex. Edit file2 without leaving vi. Edit next file. Return to version of current file at time of last write (save). Edit alternate file. Invoke vi editor from ex. Invoke one ex command from vi editor.
$vi <firsrfile> <secondfile> opening multiple files Switching to next file :n Copying multiple lines: Mk (mark start line) :lineno (goto a particular line)
ayk (creates buffer in a,we can create upto 26 buffers) Pasting bufferap To cut multiple lines replace ayk with adk..Pasting is the same ap -----Setting environment for vi----Got ot home directory :cd space vi.exrc Command o Shift o a Shift a yy 5yy yw 4yw p Shift p x 3x dd Command 5dd Shift d . (dot) u r cw Shift r Function Open mode Add below current line Add above current line Append Mode next char append at end of line Copy lines / yank line Copy lines / yank line: repeating factor 5 tines Copy word / yank word Copy word / yank word: repeating factor 4 words Paste line Paste line above Delete single character Delete 3 characters Delete line Function Delete 5 lines Delete Line from cursor to end To repeat your last action Undo last command Replace character Replace word Replace multiple characters
To Join current line with next line To check if file is modified & no of lines Search from start of Document Search from bottom of Document Continues search