vim Introduction
"How do I exit vim?" is the most famous programming joke. Let's make sure you're never stuck.
vim is powerful, fast, and everywhere. But it's weird at first because it uses modal editing.
Why vim Seems Confusing
You open vim, start typing... nothing appears. Or random things happen. You press Escape. Things get worse. You close the terminal in frustration.
Sound familiar? That's because vim works differently.
Modal Editing Explained
Most editors have one mode: you type, text appears.
vim has modes:
| Mode | Purpose | How to Enter |
|---|---|---|
| Normal | Navigate, delete, copy | Esc |
| Insert | Type text | i, a, o |
| Visual | Select text | v |
| Command | Save, quit, search | : |
Why Modes?
In Normal mode, every key is a command. d deletes, w moves forward a word, y copies. No Ctrl+This or Alt+That - just letters. Fast once you learn it.
Your First vim Session
You're now in Normal mode. Notice the cursor.
To Type Text
- Press
i(enter Insert mode) - Type your text
- Press
Esc(return to Normal mode)
To Save and Quit
- Make sure you're in Normal mode (press
Esc) - Type
:wqand press Enter
The Emergency Exits
Quit without saving:
Esc :q! Enter
Save and quit:
Esc :wq Enter
Just save:
Esc :w Enter
When in Doubt, Press Escape
If vim is doing something weird, press Esc a few times. You'll return to Normal mode where you can figure out what to do next.
Why Learn vim?
- It's everywhere: Every Unix system has vi/vim
- Fast: Once proficient, you edit faster than any GUI
- Keyboard-only: No mouse needed (servers don't have mice)
- Remote editing: Perfect for SSH sessions
- IDE integration: vim keybindings in VS Code, JetBrains, etc.
vim vs vi
vi is the original (1976). vim is "Vi IMproved" (1991) with many more features.
On most systems, vi is actually vim.
The Learning Curve
Productivity
^
| vim masters
| /
| /
| /
| /
| ___---
| /
| / nano
|/
+-----------------> Time
vim has a steep initial curve but much higher ceiling.
vimtutor - Built-in Tutorial
The best way to learn vim is the built-in tutorial:
It takes about 30 minutes and teaches you the essentials through practice. Run it a few times over a week - the repetition helps.
Learning Plan
- Complete
vimtutoronce today - Force yourself to use vim for small edits
- Run
vimtutoragain in a few days - After a week, vim will feel natural
What mode are you in when you first open vim?
Quick Reference
| Action | Keys |
|---|---|
| Enter Insert mode | i |
| Return to Normal mode | Esc |
| Save | :w |
| Quit | :q |
| Save and quit | :wq |
| Quit without saving | :q! |
Key Takeaways
- vim uses modes: Normal, Insert, Visual, Command
- Press
ito type,Escto stop typing :wqsaves and quits:q!quits without saving- Press
Escwhen confused - Learning curve is worth it
Next: essential vim commands you'll use daily.