Minimum Viable Vim
These are notes from a presentation on Vim I gave at work.
Why Vim?
Vim is everywhere - it’s installed on virtually every Unix system. Even if you primarily use another editor, knowing basic Vim is invaluable for when your preferred tools aren’t available.
The Absolute Basics
Modes
Vim has two main modes you need to know:
- Normal mode (default): For navigating and commands
- Insert mode: For typing text
- Press
ito enter insert mode - Press
ESCto return to normal mode
Essential Commands
Getting in and out
:qquit (fails if unsaved changes):q!quit without saving:wsave:wqsave and quit
Movement (in normal mode)
hleftjdownkuplright
A Typical Workflow
- Open a file:
vim test.txt - Press
ito start typing - Hit
ESCwhen done typing - Type
:wqto save and quit
Slightly More Advanced
Moving faster
wjump to next wordbjump back one word0jump to start of line$jump to end of line
Editing
dddelete current lineuundoyycopy current lineppaste
Common Gotchas
- Stuck in a mode? Hit
ESCa few times - Typed
:by accident? HitESCto cancel - Made unwanted changes?
ufor undo - Really stuck?
:q!is your escape hatch
Next Steps
Start with these basics and gradually add new commands as you get comfortable. A few suggestions for when you’re ready:
- Add the Vim plugin for VSCode if you’re a VSCode user
- Try Vimium for vim in the browser
- Visual mode (press
v) - Search (press
/) - Find and replace (
:s/old/new/g)
Published on: 2024-11-05