Working Code
First, create a practice file:
vim modes.txt
Once Vim opens, try the following three steps in order:
Step 1: Enter Insert mode with i
i
This is the first line.
You'll see -- INSERT -- at the bottom of the screen. You can type freely.
Step 2: Return to Normal mode with Esc
Press Esc. -- INSERT -- disappears. In Normal mode, every key is a command.
Step 3: Enter Command-line mode with :
From Normal mode, press : — the cursor jumps to the bottom of the screen. Type wq and press Enter:
:wq
You've now experienced all three modes!
Try It Yourself
Open the file again:
vim modes.txt
Wait, there are several ways to enter Insert mode?
i isn't the only one. Each key starts typing at a different position:
| Key | Where it starts | Mnemonic |
|---|---|---|
i | Before the cursor | insert |
a | After the cursor | append |
o | New line below | open below |
I | Start of the line | Insert at start |
A | End of the line | Append at end |
O | New line above | Open above |
Try them one by one:
- From Normal mode, press
A— you start typing at the end of the line immediately! - Press
Esc, theno— a new line opens below and you're in Insert mode! - Press
Esc, thenO— a new line opens above.
Get a feel for which one fits your flow best.
"Why?" — Why do we need modes?
Think about driving a car:
| Gear | Vim mode | What it does |
|---|---|---|
| Drive (D) | Insert | Type text |
| Park (P) | Normal | Issue commands (move, delete, yank) |
| Reverse (R) | Command-line | System commands (save, quit, search) |
Just as you shift gears while driving, you switch to the mode that matches what you want to do.
In a regular editor, pressing d types the letter d. In Vim's Normal mode, pressing d is a delete command. The same key behaves completely differently depending on the mode. That's how Vim turns every key on your keyboard into a command.
How to check your current mode
Look at the status bar at the bottom of the Vim screen to see your current mode:
| Indicator | Mode |
|---|---|
| (nothing) | Normal |
-- INSERT -- | Insert |
-- VISUAL -- | Visual (covered later) |
: (cursor at bottom) | Command-line |
When you're unsure, press Esc once or twice. You always return to Normal mode. Esc is your "home base."
Common mistake: typing in the wrong mode
If you start typing without realizing you're in Normal mode, strange things happen:
Say you wanted to type "hello" but you're in Normal mode:
h→ move cursor lefte→ move to end of wordl→ move cursor rightl→ move cursor righto→ open a new line below + enter Insert mode!
If the cursor suddenly jumps around and a new line appears, you were typing in Normal mode. Don't panic — press Esc → u (undo).
Deep Dive
- Open a file with
vim practice-modes.txt. - Press
i, type "First line", and pressEsc. - Press
o, type "Second line", and pressEsc. - Press
Oabove the first line and type "Title", then pressEsc. - Move to the end of the first line and press
Ato append " (added)", then pressEsc. - Save with
:wqand check the result withcat practice-modes.txt.
Quiz
Why doesn't your text appear when you start typing right after opening Vim?
Which key lets you start typing immediately at the end of the current line?
You don't know what mode you're in. What should you do first?