What this post covers
This post is for a reader who can open Vim in a terminal but still feels unsure about when to type, when to move, and why hjkl matters.
By the end, you will be able to:
- tell what mode you are in
- switch between Normal, Insert, and Command-line mode without panic
- move by character, word, line, and file
- save or quit with basic
: commands
Why Vim uses modes
Vim separates typing from commands. That design feels strange at first, but it solves a real problem: the same keys can either insert text or control the editor.
Think of the three modes in this post like this:
There is also a Visual mode in Vim, but this post stays with the three modes you need first.
The safest habit for beginners is simple: when you are not sure what state Vim is in, press Esc once or twice and return to Normal mode.
Get ready
Create a small practice file so every motion in this post is easy to repeat.
cd ~
cat > test-nav.txt << 'EOF'
Line 1: Welcome to Vim navigation
Line 2: Learning hjkl movement
Line 3: Words can be jumped
Line 4: With w e b commands
Line 5: This is the fifth line here
Line 6: Almost at the end
Line 7: Final line of this file
EOF
Then open it in Vim.
Ready. Press Replay to run the scripted session.
Exercise 1: Switch modes safely
Start in Normal mode. That is Vim's default mode after you open a file.
How to tell which mode you are in
- no banner at the bottom: Normal mode
-- INSERT --: Insert mode
: prompt on the last line: Command-line mode
Normal mode -> Insert mode
Press i to start typing before the cursor.
Ready. Press Replay to run the scripted session.
Type a few characters if you want to feel the difference. The important point is that keys now insert text instead of acting like Vim commands.
Insert mode -> Normal mode
Press Esc to stop typing and return to Normal mode.
Ready. Press Replay to run the scripted session.
Pressing Esc again in Normal mode does nothing, so repeated Esc is a safe reset habit.
Normal mode -> Command-line mode
Press : to open the command line at the bottom.
Ready. Press Replay to run the scripted session.
Useful first commands:
:w save the file
:q quit
:wq save and quit
:q! quit without saving changes
Press Esc to cancel the prompt and return to Normal mode.
Before navigation: a note on arrow keys
Some beginners press an arrow key in Vim and see odd letters such as A, B, C, or D. That usually points to a terminal or compatibility setup problem, not to navigation itself.
If that happens, put this at the top of ~/.vimrc and reopen Vim:
set nocompatible
You may also see guides that recommend set term=xterm-256color, but that is about terminal capabilities and color support, not the main fix for legacy arrow-key behavior.
Even if your arrow keys work, practice hjkl. The point is to keep your hands on the keyboard's main typing area.
Exercise 2: Move with hjkl
These are the four basic cursor motions in Normal mode.
| Key |
Direction |
h |
left |
j |
down |
k |
up |
l |
right |
You can also put a count in front of a motion. For example, 3j means "move down three lines."
Practice plan
Start from the top of the file with gg, then try this sequence.
| Command |
Result |
3j |
move to Line 4 |
k |
move back to Line 3 |
10l |
move ten columns to the right |
5h |
move five columns to the left |
Ready. Press Replay to run the scripted session.
Historically, hjkl became common because early terminals used those keys for cursor arrows. Today the practical advantage is that your hands stay near the home row.
Exercise 3: Move by word with w, e, b
Character-by-character movement is fine for short distances. For longer jumps, word motions are faster.
What counts as a word here
In Vim, a word usually means a run of letters, numbers, or underscores. Spaces and punctuation create boundaries.
Examples:
hello -> one word
var_name -> one word
arg1, -> arg1 is the word, the comma is punctuation
Core word motions
| Command |
Meaning |
w |
jump to the start of the next word |
e |
jump to the end of the current word, or the next word if you are on whitespace |
b |
jump back to the start of the previous word |
Start at the beginning of Line 1 and try this sequence.
| Command |
Landing point |
w |
Welcome |
w |
to |
w |
Vim |
e |
end of Vim |
w |
navigation |
e |
end of navigation |
b |
navigation |
b |
Vim |
The main idea is not to memorize a picture. It is to notice that Vim gives you a small vocabulary for short jumps and larger jumps.
Exercise 4: Move by line and file
These motions help when you already know roughly where you need to go.
Line motions
| Command |
Meaning |
Why it helps |
0 |
go to column 0, before any leading spaces or tabs |
useful when you want the absolute start |
^ |
go to the first non-whitespace character |
useful in indented code |
$ |
go to the end of the line |
useful before appending text |
File motions
| Command |
Meaning |
gg |
go to the first line |
G |
go to the last line |
5G |
go to line 5 |
Try one practical mini-drill:
- Type
5G to jump to Line 5.
- Type
$ to jump to the end of that line.
- Type
0 to return to the absolute beginning.
- Type
^ to move to the first non-whitespace character.
If your Vim uses a non-default startofline setting, some line jumps may keep your current column. Beginners can usually ignore that detail until later.
Bonus: screen navigation
When a file is taller than the visible window, these commands help you move by screen instead of by exact line number.
| Command |
Meaning |
Memory hook |
Ctrl+f |
one screen forward |
f for forward |
Ctrl+b |
one screen backward |
b for back |
Ctrl+d |
half a screen down |
d for down |
Ctrl+u |
half a screen up |
u for up |
H |
move cursor near the top of the screen |
high |
M |
move cursor near the middle of the screen |
middle |
L |
move cursor near the bottom of the screen |
low |
Treat these as bonus motions for larger files. The earlier sections are the real essentials for this stage.
Quick reference
| Situation |
Best first choice |
| I need to type text |
i |
| I want to stop typing |
Esc |
| I need a tiny cursor move |
h, j, k, l |
| I need to jump by word |
w, e, b |
| I need the start or end of a line |
0, ^, $ |
| I need the top or bottom of the file |
gg, G |
| I need to save or quit |
:w, :q, :wq, :q! |
Common issues
hjkl does nothing
You are probably not in Normal mode. Press Esc, then try again.
: appears inside the file instead of opening a prompt
You are probably still in Insert mode. Press Esc first.
:q says there are unsaved changes
Use :wq to save and quit, or :q! to quit without saving.
I keep forgetting when to use which motion
Use this order of thought:
- character distance ->
hjkl
- word distance ->
w, e, b
- line distance ->
0, ^, $
- file distance ->
gg, G, nG
Wrap-up
You now have the core movements that make Vim feel different from a regular text editor.
- modes tell Vim whether you want to type, move, or run a command
Esc is your reset key
- motions become more efficient as the distance gets larger
In the next post, these motions start paying off because you will combine them with editing commands such as delete, copy, and paste.
Next episode
👉 Vim Series 4: Editing Commands--Delete, Copy, Paste
💬 댓글
이 글에 대한 의견을 남겨주세요