Vim Commands Part I - Moving Around

Overview

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

MovementCommand
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

MovementCommand
Move current line to top of screen and scroll and leave the cursor in the same columnzt
Move current line to center of screen and scroll and leave the cursor in the same columnzz
Move current line to bottom of screen and scroll and leave the cursor in the same columnzb

Move within a screen

MovementCommand
Move to home—the top line of screenH
Move to middle line of screenM
Move to bottom line of screenL

Movement by line

Move by line

MovementCommand
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

MovementCommand
Move the cursor to the beginning of the line0
Move to the first nonblank character of the current line^
Move the cursor to the end of the line$

Movement by text blocks

MovementCommand
Move to end of worde
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

MovementCommand
Search forward for pattern/pattern ENTER
Search backward for pattern?pattern ENTER
Repeat last searchn
Repeat last search in opposite directionN
Repeat last search forward/
Repeat last search backward?

Current Line Searches

f is short for find, and t stands for to, meaning up to.

MovementCommand
Find(move cursor to) the next occurrence of x in the line, where x stands for any characterfx
Find(move cursor to) the previous occurrence of x in the lineFx
Find(move cursor to) the character before the next occurrence of x in the linetx
Find(move cursor to) the character after the previou occurrence of x in the lineTx
Repeat the previous find command in the same direction;
Repeat the previous find command in the opposite direction,

Movement by line number

MovementCommand
Go to given line nnG
Go to end of fileG
Return to previous mark or context` ` (two backticks)
Return to beginning of line containing previous mark''
Show current line (not a movement command)^G
all posts

You might also like posts tagged with #vim:

Comments

© 2022 Youngjae Jay Lim. All Rights Reserved, Built with Gatsby