Ever since I switched to Vim from VS Code, I always wanted to write down and organize useful Vim commnds that I've learned throughout the years. Because there are so many commands that I want to share, I am going to break them down in several parts. The first part is for moving around in Vim and these commands are essential to take your journey into Vim world.
Moving Around in Vim
Movement by screens
Scrolling the screen
Movement
Command
Scroll forward one screen
^F
Scroll backward one screen
^B
Scroll forward a half screen
^D
Scroll backward a half screen
^U
Scroll forward one line
^E
Scroll backward one line
^Y
Repositioning the screen with z
Movement
Command
Move current line to top of screen and scroll and leave the cursor in the same column
zt
Move current line to center of screen and scroll and leave the cursor in the same column
zz
Move current line to bottom of screen and scroll and leave the cursor in the same column
zb
Move within a screen
Movement
Command
Move to home—the top line of screen
H
Move to middle line of screen
M
Move to bottom line of screen
L
Movement by line
Move by line
Movement
Command
Move to the first nonblank character of the next line
+(Same as Enter)
Move to the first nonblank character of the previous line
-
Movement on the current line
Movement
Command
Move the cursor to the beginning of the line
0
Move to the first nonblank character of the current line
^
Move the cursor to the end of the line
$
Movement by text blocks
Movement
Command
Move to end of word
e
Move to end of word (ignore punctuation)
E
Move to beginning of current sentence
(
Move to beginning of next sentence
)
Move to beginning of current paragraph
{
Move to beginning of next paragraph
}
Move to beginning of current section
[[
Move to beginning of next section
]]
Movement by searches
Pattern searches
Movement
Command
Search forward for pattern
/pattern ENTER
Search backward for pattern
?pattern ENTER
Repeat last search
n
Repeat last search in opposite direction
N
Repeat last search forward
/
Repeat last search backward
?
Current Line Searches
f is short for find, and t stands for to, meaning up to.
Movement
Command
Find(move cursor to) the next occurrence of x in the line, where x stands for any character
fx
Find(move cursor to) the previous occurrence of x in the line
Fx
Find(move cursor to) the character before the next occurrence of x in the line
tx
Find(move cursor to) the character after the previou occurrence of x in the line
Tx
Repeat the previous find command in the same direction
;
Repeat the previous find command in the opposite direction
,
Movement by line number
Movement
Command
Go to given line n
nG
Go to end of file
G
Return to previous mark or context
` ` (two backticks)
Return to beginning of line containing previous mark
Comments