TracksPractical Coding FoundationsTerminal EditorsVim Survival Guide(3 of 3)

Vim Survival Guide

Vim has a reputation for being confusing, and there's a famous joke: "How do you generate a random string? Put a first-year developer in vim and tell them to exit." But vim is installed on virtually every Unix-like system, so knowing the basics is essential. This lesson gives you survival skills — not mastery, just enough to get in, make changes, and get out.

Why Vim Is Different

Vim is a modal editor, meaning it has different modes for different tasks:

  • Normal mode — For navigation and commands (the default when you open vim)
  • Insert mode — For typing text
  • Command mode — For saving, quitting, and other operations

This design seems strange at first, but it allows experienced users to edit extremely efficiently without ever touching a mouse.

Opening a File

When vim opens, you're in Normal mode. If you start typing, nothing sensible happens — you're issuing navigation commands, not inserting text.

Entering Insert Mode

To actually type text, press i to enter Insert mode. You'll see -- INSERT -- at the bottom of the screen. Now you can type normally.

When you're done typing, press Esc to return to Normal mode. This is crucial — you must be in Normal mode to save or quit.

Saving and Quitting

From Normal mode, press : to enter Command mode. You'll see a colon appear at the bottom of the screen. Then type your command:

  • :w — Write (save) the file
  • :q — Quit vim
  • :wq — Write and quit (save, then exit)
  • :q! — Quit without saving (discard changes)

The exclamation mark in :q! means "force" — do it even if there are unsaved changes.

The Complete Survival Workflow

Here's everything you need in one sequence:

  1. vim filename — Open the file
  2. Press i — Enter Insert mode
  3. Make your edits — Type normally
  4. Press Esc — Return to Normal mode
  5. Type :wq — Save and quit
  6. Press Enter — Execute the command

If something goes wrong and you're confused, press Esc a few times (to ensure you're in Normal mode), then type :q! and press Enter. You'll exit without saving — a safe escape hatch.

Why Learn More Later?

Vim rewards investment. Developers who master it edit text faster than seems possible, navigating and transforming code with minimal keystrokes. But that mastery takes time.

For now, these survival skills are enough. When you encounter vim unexpectedly — perhaps git opens it for a commit message — you won't panic. You'll make your edit, save, and exit like a professional.

See More

Further Reading

You need to be signed in to leave a comment and join the discussion