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
i
to enter insert mode - Press
ESC
to return to normal mode
Essential Commands
Getting in and out
:q
quit (fails if unsaved changes):q!
quit without saving:w
save:wq
save and quit
Movement (in normal mode)
h
leftj
downk
upl
right
A Typical Workflow
- Open a file:
vim test.txt
- Press
i
to start typing - Hit
ESC
when done typing - Type
:wq
to save and quit
Slightly More Advanced
Moving faster
w
jump to next wordb
jump back one word0
jump to start of line$
jump to end of line
Editing
dd
delete current lineu
undoyy
copy current linep
paste
Common Gotchas
- Stuck in a mode? Hit
ESC
a few times - Typed
:
by accident? HitESC
to cancel - Made unwanted changes?
u
for 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