Page 1

vi editor commands Two modes of the vi editor • Command mode: Can perform commands in the vi editor • Editing (Insert) mode: Can type information in the vi editor Why learn the vi editor? • The vi editor is the most frequently used editor in all flavors of Linux and UNIX • It is also useful in case the flavor of Linux/UNIX does not have a graphical interface Navigation Commands Command
h j k l w b e <ctrl> + <ctrl> + <ctrl> + <ctrl> + 0 (zero) $ <ctrl> +

Description

d (or D) u (or U) F B g

Moves cursor to the left Moves cursor down a line Moves cursor up a line Moves cursor to the right Moves cursor to the next word Moves cursor to the previous word Moves cursor to the end of the word Scroll down half-screen Scroll up half-screen Scroll down one page Move back one page Move cursor to the beginning of the line Move cursor to the end of the line Displays the status (where the cursor is in the file)

A “cheat sheet” of commands for the vi editor

Page 2

vi editor commands Modification Commands Command
yy Nyy P p rx rtext<esc> x dd dw cw cc j u . (dot) fx Fx /pattern ?pattern

Description

Copies current line Copys n amount of lines Pastes data below current line Pastes data above current line Replaces the current character with a specific character Replaces characters at the current cursor position with the text Deletes the character at the current cursor position Delete a line Delete a word Changes a word Changes a line Joins lines Undoes the last change made Repeats the last change made Finds the specific character on the current line after the current cursor position Finds the specific character on the current line before the current cursor position Finds the next line containing the specified pattern Finds the previous line containing the specified pattern.

A “cheat sheet” of commands for the vi editor

Page 3

vi editor commands Insert/Command Commands Command
i a A I o O <esc>

Description

Puts vi in insert mode – cursor stays in current position Puts vi in insert mode – moves cursor to the next position Puts vi in insert mode – moves cursor to the end of the line Puts vi in insert mode – moves cursor to the beginning of the line Puts vi in insert mode – Inserts a blank line below the current line Puts vi in insert mode – inserts a blank line above the current line Switch from insert mode to command mode

File Processing Commands Command
:q! :q :w<filename> :wq :e<filename> :!<command> Closes without saving Closes Saves as <filename> Saves and closes Open a file Run a shell command

Description

A “cheat sheet” of commands for the vi editor

Sign up to vote on this title
UsefulNot useful