Right, let’s get you functional in vim. Forget the legends about how you can only exit it by rebooting the machine. It’s an editor, not a hostage situation. The secret is that vim is a language for manipulating text, not just a place to type. You’re about to learn its basic grammar.

First, the most important thing to internalize: vim has modes. You are not always typing. You start in Normal mode (also called command mode). This is where you navigate, delete, copy, paste, and issue commands. It feels weird for about ten minutes, and then you’ll wonder how you ever lived without it. To actually insert text, you need to enter Insert mode. More on that in a second.

Your New Arrow Keys: hjkl

Let’s address the elephant in the room: why hjkl? Blame history. The ADM-3A terminal Bill Joy used to create vi (vim’s predecessor) didn’t have physical arrow keys. These keys were the arrows, printed right on the keycaps. It’s not a cultish initiation ritual; it’s ergonomics. Moving your hand all the way to the arrow keys is a productivity killer. Keeping your right hand on jkl; is home row nirvana.

  • h moves left.
  • j moves down.
  • k moves up.
  • l moves right.

Yes, it feels alien. Do it for 15 minutes. Muscle memory is a hell of a drug. Trust me, you’ll eventually try to hit j to scroll down in your web browser and feel a profound sense of loss.

How to Actually Type Something: i and a

You’re in Normal mode, cursor parked on a character. You need to add text.

  • i (for insert) puts you into Insert mode before the current character.
  • a (for append) puts you into Insert mode after the current character.

This distinction is everything. If your cursor is on the o in world, hitting i lets you type before it (wor*ld), while a lets you type after it (wo*rld). It’s the difference between fixing a typo and adding to the end of a word. To escape from Insert mode and return to the safety of Normal mode, you hit <ESC>. That key is now your best friend and your panic button.

The Big Guns: yy, dd, and p

This is where the power starts to show. You don’t “highlight, right-click, copy.”

  • yy (yank yank) copies the entire current line. Think of it as “yanking” the line into a buffer.
  • dd (delete delete) cuts the entire current line. It also acts as the “delete line” command.
  • p (put) pastes whatever you last yanked or deleted after the current line. P (capital) pastes before the current line.

These commands are line-oriented. yy doesn’t care where your cursor is on the line; it grabs the whole thing. This is a core vim philosophy: you operate on logical chunks of text (words, lines, paragraphs), not just arbitrary character blocks.

# Let's say you have this in your file:
Line one is okay.
Line two is the best line.
Line three is mediocre.

# With your cursor on "Line two", you type:
dd

# Now you have:
Line one is okay.
Line three is mediocre.

# You immediately realize your mistake. You just deleted the best line!
# So you paste it back. Hit:
p

# And now it's pasted *after* "Line three", which is probably not what you wanted.
Line one is okay.
Line three is mediocre.
Line two is the best line.

# Better to use undo first (next command!) and then do it properly.

Your Undo Button: u

You will mess up. Constantly. u is undo. It’s straightforward, beautiful, and will save your sanity. Unlike some modern editors, vim’s undo is infinitely deep and branches beautifully, but for now, just know that u reverses your last change. <CTRL-r> redoes what you just undid.

How to Save, Quit, and Finally Breathe: :wq

The colon : introduces a command-line command. This is the third major mode, aptly named Command-line mode.

  • :w (write) saves the file. Do this early, do this often.
  • :q (quit) exits vim. It will yell at you if you have unsaved changes, because it’s not your babysitter.
  • :wq (write and quit) is your most common exit strategy. Save and get out.
  • :q! (quit, dammit!) forces an exit, throwing away any changes since your last save. Use this when you’ve created a monstrosity and just need to escape.

A common pitfall? Trying to type :wq from Insert mode. It won’t work. You’ll just type :wq into your document. Always, always make sure you’re in Normal mode (<ESC>) first. If you do accidentally type it, just mash <ESC> until you’re sure you’re in Normal mode, then use dd to delete the mistaken line.

There you go. You now know enough to edit text, navigate, copy/paste, undo, and exit without summoning a system administrator. It’s a start. A powerful, slightly awkward, but incredibly efficient start.