vimtutor
To move the cursor, press the h, j, k, l keys as indicated.
:q! exits the editor, DISCARDING any changes you have made.
Press x to delete the character under the cursor.
Use :wq to save a file and exit.
Press i to insert text.
Type a to insert text AFTER the cursor.
Press A to append text.
Type o to open a line below the cursor and place you in Insert mode.
Type O to open a line above the cursor and place you in Insert mode.
Press <ESC> will place you in normal mode.
Type dw to delete a word.
Type d$ to delete to the end of the line.
Type de to delete to the end of the current word.
Typing a number before a motion repeats it that many times.
- Type
2wto move the cursor two words forward. - Type
3eto move the cursor to the end of the third word forward. - Type
0(zero) to move to the start of the line. - Type
$to move to the end of the line.
Typing a number with an operator repeats it that many times. (such as d number motion):
- Type
d2wto delete the two UPPER CASE words
Type dd to delete a whole line. Type 2dd to delete two lines.
Press u to undo the last commands, U to fix a whole line.
Type CTRL-R to redo the commands (undo the undo’s)
Type p to put previously deleted text after the cursor.
Type r <x> to replace the character at the cursor with the character you want to have such as x.
To change until the end of the current word, type ce .
To change until the end of a word, type cw .
To change until the end of line type c$ .
Type CTRL-G to show your location in the file and the file status.
Type G to move to a the bottom of the file.
Type gg to move you to the start of the file.
Type <number> G moves to that line number.
Type / followed by a phrase to search for the phrase.
- To search for the same phrase again, simply type
n. - To search for the same phrase in the opposite direction, type
N. - To search for a phrase in the backward direction, use
?instead of/. - To go back to where you came from press
CTRL-O. Repeat to go back further.CTRL-Igoes forward.
Type % to find a matching ),], or } .
Type :s/old/new to substitute ’new’ for ‘old’:
- type
:#,#s/old/new/gwhere #,# are the line numbers of the range of lines where the substitution is to be done. - Type
:%s/old/new/gto change every occurrence in the whole file. - Type
:%s/old/new/gcto find every occurrence in the whole file, with a prompt whether to substitute or not.
Type :! followed by an external command to execute that command.
To save the changes made to the text, type :w <FILENAME>.
Start Visual mode with v.
To save part of the file, type v motion :w FILENAME
Type a capital R to replace more than one character.
Use the y operator to copy text and p to paste it.
Set the ‘ic’ (Ignore case) option by entering: :set ic so a search or substitute ignores case. Prepend “no” to switch an option off: :set noic
:set ic‘ignorecase’ ignore upper/lower case when searching:set isincsearch’ show partial matches for a search phrase:set hls‘hlsearch’ highlight all matching phrases
Use the on-line help system with <F1> or :help
- Type
CTRL-W CTRL-Wto jump from one window to another. - Type
:q <ENTER>to close the help window.
Enable Vim features by editing the “vimrc” file. :help vimrc-intro
When typing a : command, press CTRL-D to see possible completions.
Press <TAB> to use one completion.