Editing files with Vim
tl;dr
Vim has three modes and you land in the one that ignores your typing. `i`, `ESC`, `:wq` to save and `:q!` to bail — that's enough to edit a file on any server, and the rest is optional forever.
You already have VS Code, and it is better at almost everything. The reason to learn Vim isn't that it beats your editor — it's that it is already installed on the server you just rented, and VS Code is not.
Three modes, and you start in the wrong one
This is the whole reason Vim feels broken the first time. You open a file, type, and nothing appears — because you are in normal mode, where letters are commands, not text.
- normal — where Vim opens. Keys are navigation and commands.
- insert —
i. Now you're typing text. Vim prints-- INSERT --at the bottom, which is how you check where you are. - command —
:. Saving, quitting, searching.
ESC returns to normal from anywhere. That single key is most of what saves you.
The exercise
cd ~
mkdir temp
cd temp
vi test # vim test works too — same editor
Then i, write a few lines, ESC, and :wq to write and quit. vi test
creates the file if it doesn't exist, so touch first is optional.
The four keys that get you out
ESC | back to normal mode, from anywhere |
u | undo the last change (in normal mode) |
:wq | write and quit |
:q! | quit and throw the changes away |
:syntax on | colour the code you're editing |
That last one is the escape hatch. Plain :q refuses when you have unsaved
changes; the ! means do it anyway. You will need it the first time you open
a file by accident.
Why bother past that
Jem's argument isn't speed for its own sake — it's that once you stop reaching for the mouse, both hands stay on the keyboard. The people he's seen use Vim at work are genuinely fast, but he's blunt about the cost: it takes a long time and real dedication, because it isn't a natural way to work for most people.
So this lesson stays at the surface deliberately — about ten minutes, enough to open a file on a server, change a line, and get out. If you want the rabbit hole, the course points at ThePrimeagen's four-hour Vim Fundamentals and openvim.com.