TL;DR Run vimtutor and be enlightened!
Simple Editing
Action | Command |
---|
Insert | i |
Append | a |
Append to end of line | A |
Insert line (above) | O |
Insert line (below) | o |
Delete char | x |
Delete word | dw |
Delete line | dd |
Delete to end of line | d$ |
Undo Change | u |
Undo Line | U |
Redo | Ctrl+R |
Advanced Editing
Action | Command |
---|
Visual Selection | v |
Toggle Case | select word and ~ |
Copy-and-paste | yy (copy) and p (put) |
Cut-and-paste | dd (cut line) and p (put) |
Replace character | r (followed by the char to be replaced) |
Replace mode | R (enters replace mode) |
Change word | ce |
Change everything to end of line | c$ |
Delete in parenthesis | di( |
Delete in quotes | di" |
Delete all lines in file | :1,$d |
Global replace | :%s/old/new/g |
Global replace with prompt | :%s/old/new/gc |
Navigation
Action | Command |
---|
Navigate to beginning of line | 0 |
Navigate to end of line | $ |
Navigate to beginning of next word | w |
Navigate to end of next word | e |
Move to end of file | G |
Move to start of file | gg |
Go to line number | :<line number> |
Previous Location | Ctrl+O |
Next Location | Ctrl+I |
Navigate to matching brace (cursor on the brace) | v% |
Search
Action | Command |
---|
Search for pattern | /<pattern> |
Search Backwards | ?<pattern> |
Next Hit | n |
Previous Hit | N |
Match parentheses | % (at the opening/closing parenthesis) |
Set Search Options
Action | Command |
---|
Ignore case | :set ic |
Show partial matches | :set is |
Highlight matching phrases | :set hls |
Unset options | :set no<option> |
Text stats (e.g: word count) | g CTRL-G |
External Commands
Action | Command |
---|
Run External Command | :!<command> |
Run command and dump output | :.!<command> |
Command completion | :!<start-of-command>Ctrl+D |
Save file with sudo | :w !sudo tee % |
Spell Check (:set spell spelllang=en_gb)
Action | Command |
---|
Navigate to the next misspelled word | ]s |
Navigate to the previous misspelled word | [s |
Alternatives to misspelled word | z= |
Add word to dictionary | zg |
Mark word as incorrect | zw |