Command mode versus Input mode
Vi starts in command mode bydefault.
To switch vi editor to input mode you need to enter any one of several vi input commands.
Once in input mode, any characters you type is taken to be text and is added to the file.
You cannot execute any commands until you exit input mode.
To exit input mode, press escape (Esc) key.
Starting and Leaving vi
To enter vi editor
To Exit, saving changes
To Exit as long as there have been no changes
To Exit and save changes if any have been made
To Exit and ignore any changes
Input commands
To Append after cursor
To Insert before cursor
To open line below
To open line above
To Insert file after current line
Any of these commands leaves vi in input mode until you press
Esc key.
Change commands (Input mode)
The change command is a deletion command.
It leaves the editor in insert mode.
It is performed by typing
c followed by a motion.
To Change word
Change to the end of the line
To Change the whole line
Changes during insert mode
To Back one character
To Back one word
To Back to beginning of insert
Cursor and Window motions
Move left
Move down
Move up
Move right
Move to next word
Move to next blank delimited word
Move to the beginning of the word
Move to the beginning of blank delimited word
Move to the end of the word
Move to the end of blank delimited word
Move a sentence backward
Move a sentence forward
Move a paragraph backward
Move a paragraph forward
Move to the beginning of the line
Move to the end of the line
Move to the first line of the file
Move to the last line of the file
Move to nth line of the file
Move to top of screen
Move to middle of screen
Move to button of screen
Page up
Page down
Deletion, Recovering and Undo commands
Delete n lines to general buffer
Delete word to general buffer
Delete n word
Delete to end of sentence
Delete previous word
Delete to end of line
Put general buffer after cursor
Put general buffer before cursor
Undo last change
Undo all changes on line
Rearrangement commands
Yank (copy) line to general buffer
Yank 6 lines to buffer z
Yank word to general buffer
Delete 9 lines to buffer a
Delete 9 lines; Append to buffer a
Put text from buffer a after cursor
Put general buffer after cursor
Put general buffer before cursor
Join lines
Regular expressions (search strings)
Matches beginning of line
Matches end of line
Matches any single character
Matches any previous character
Matches any character
Search and replace commands
To Transpose (swap) adjacent characters
:[address]s/old_text/new_text/
Where
address parameter values can be:
'
.' Current line
'
n' Line number n
'
.+m' Current line plus m lines
'
$' Last line
'
%' Entire file