Skip to content

Vi

Vi Linux text editor commands

Notes: denotes the Esc key, and denotes the Enter key. The expression means that you should enter a command, means that you should enter a filename, and means that you should enter a character or number. The symbol ^ (caret) means that you should hold down the Ctrl key while pressing the indicated letter.

Vi editor command keys:

ZZ Exit, saving changes t Up to forward Q Enter ex mode T Back up to End of insert | Go to column : Execute ex command w,W Forward one word :! Shell command b,B Back one word ^g Show filename/size e,E End of word ^f Forward one screen ^h Erase last character ^b Back one screen ^w Erase last word ^d Forward half screen ^? Interrupt ^u Backward half screen ~ Toggle character case G Go to line a Append after / Search forward for i,I Insert before ? Search backward for A Append at end of line n Repeat last search o Open line below N Reverse last search O Open line above ]] Next section/function r Replace character [[ Previous section/function R Replace characters % Find matching () { or } d Delete ^l Redraw screen dd Delete line ^r Refresh screen c Change
z Current line at top y Yank lines to buffer z- Current line at bottom C Change rest of line ^e Scroll down one line D Delete rest of line ^y Scroll up one line s Substitute character `` Previous context S Substitute lines
H Home window line J Join lines
L Last window line x Delete after
M Middle window line X Delete before

  •   Next line                      Y      Yank current line   
    

hjkl Cursor movement: p Put back lines
left/down/up/right P Put before
0 Beginning of line > Shift line right
f Find forward u Undo last change
F Find backward U Restore current line

Ex mode commands:

q Quit set Enable option q! Quit, discard changes set no Disable option r Read in file set all Show all options sh Invoke shell vi Vi mode wq Write and quit w Write file w! Overwrite file

Options: autoindent Automatic line indentation autowrite Write before quit ignorecase Ignore case in searches number Display line numbers showmatch Show matches to ) and } as typed terse Quiet mode wrapscan Wraparound in searches wrapmargin Automatic line splitting