#Vim Basic Commands
###Modes
i
: change to insert mode to edit text
v
: change to visual mode to select text
Esc
: Normal mode to navigate through the text file
###Moves (Normal mode)
h
: move left | l
: move right
j
: move up | k
: move down
w
: move to the beginning to the next word to the right
e
: move to the end of the next word to the right
b
: move to the beginning of the previous word (to the left)
you can combine keys to move around
3+w
: will move to the beginning of the 3rd word to the right.
7+e
: will move to the end of the 7th word to the right.
2+h
: will move 2 characters to the left.
%
: jump to the matching parentheses or bracket under the cursor.
0
: beginning of line | $
: end of line
gg
: jump to the beginning of the file | G
: jump to the end of the file
3+G
: jump to the 3rd line to the file
###Modify text file
o
: insert a new line under the current one | O
: insert a new line above the current one
3+i+go+Esc
: insert 3 'go'. In this way you can insert a repeated pattern.
x
: deletes the character under the cursor | X
: deletes the characters to the left of the cursor.
r
: replace the character under the cursor without changing to insert mode
a
: append from the position of the cursor to the right
d
: delete command, it need to be combined with a movement. d+w
: deletes the first word to the right.
###Find
/
: find text, you can use RegEx too to match a pattern | n
: moves to the next | N
: moves to the previous
*
: find the next occurrence of the word under the cursor
#
: find the previous occurrence of the word under the cursor
f+w
: find the first occurrence of 'w' to the right of the coursor.
you can combine the numbers with this find
3+f+w
: will find the third occurrence of 'w' in the document
.
: repeats the last command => d+2+w
deletes 2 words to the right of the cursor, pressing .
will keep deleting words 2 by 2
:w
: save | :q
: quit | :q!
: quit without saving | u
: undo | ctrl+r
: redo | :help
: help menu