Pablo Murad something new again, and me again

Vim without the mystery

Vim without the mystery

2026-11-19, originally published on pablomurad.com.

← all Pablo Murad texts

Vim has a reputation. The most famous joke about it is that nobody knows how to leave: a file opens by accident, the keyboard stops doing what keys normally do, and the only way out seems to be closing the terminal.

All of that confusion comes from one idea that nobody explains at the door. Once it clicks, Vim stops being a puzzle and starts feeling like a small language for talking to text. This post goes from "how do I get out" to editing comfortably, one step at a time. The best way to read it is with a terminal open, running vim practice.txt, trying things along the way. Nothing here can break.

First things first: the way out #

If only one thing sticks, make it this. Press Esc, then type one of these and hit Enter:

The colon opens a small command line at the bottom of the screen, and whatever is typed there runs on Enter. When everything feels lost, Esc a couple of times always leads back to where it started.

Why Vim works like this #

Keyboard layout of the Lear Siegler ADM-3A terminal: the H, J, K and L keys carry printed arrows for left, down, up and right, and the ESC key sits at the left end of the row where Tab is on modern keyboards.

The story starts in 1976, at UC Berkeley. Bill Joy added a full-screen "visual" mode to ex, a line editor,1 and that mode became vi. He wrote it on a Lear Siegler ADM-3A terminal, and that keyboard explains a lot. It had no separate arrow keys: the arrows were printed on H, J, K and L. And Esc sat where Tab is on today's keyboards, one finger away. Moving with hjkl and pressing Esc all the time made perfect sense on that machine, and the habit stuck.

In 1988 Bram Moolenaar, a Dutch programmer, started writing a vi clone for the Amiga. He called it Vi IMitation. It went public in 1991, and around version 2.0, in 1993, the name became Vi IMproved. Bram looked after Vim for more than thirty years, until he died in 2023.2 A group of longtime contributors maintains it now, and Vim 9.2 came out in February 2026.

There's also Neovim, a fork started in 2014. Everything in this post works the same way in both.

The one idea: modes #

In most editors, the keyboard always types. Press d and a "d" shows up on the screen.

Vim has modes, and the keyboard means different things in each one:

Diagram of Vim's modes: Normal mode, highlighted as home where keys are commands, goes to Insert mode with i, a, o, I, A or O and back with Esc; to Visual mode with v, V or Ctrl-v and back with Esc, d or y; and to Command-line mode with : and back with Enter or Esc.
- Normal mode: where Vim starts, and where most of the time goes. Keys are commands: d deletes, w jumps to the next word, u undoes. - Insert mode: the keyboard types, like in any other editor. The bottom of the screen says -- INSERT --. - Visual mode: select text first, then act on the selection. - Command-line mode: the : from the way out. It runs longer commands, like saving or search and replace.

The trick is to see Normal mode as home. Insert mode is where text gets typed, and Esc comes back. Editing in Vim is mostly moving around and changing things, and typing new text is a short trip. That's why the "typing" mode isn't the default.

Typing text #

From Normal mode, any of these goes into Insert mode, each starting in a different spot:

Type the text, press Esc, and it's back home. A is worth trying on any line: it's the fastest way to add something at the end, no matter where the cursor is.

Moving around #

The arrow keys work, and there's no shame in using them at first. These are the moves worth learning next, because they save the most time:

Most moves accept a number in front: 3w jumps three words, 5j goes down five lines.

The grammar: verb, then where #

This is the part where Vim starts to make sense. Commands are built like short sentences: a verb, then a place.

The verbs:

Any verb in front of any motion from the last section makes a command:

A verb typed twice acts on the whole line: dd deletes a line, yy copies it, cc changes it, >> indents it. A number multiplies: 3dd deletes three lines.

Then there are text objects, which are the real magic. Instead of "from here to there", they mean "this thing the cursor is in", so the cursor can be anywhere inside it:

So ciw reads "change inner word", di( is "delete inside parentheses", and yap is "yank a paragraph". Picture this line, with the cursor somewhere on the word print:

print("hello")

Type ci", then world, then Esc. Vim finds the next quoted text on the line, empties it, waits for the new text, and the line becomes print("world"). With a handful of verbs and objects, the combinations come for free, with nothing to memorize one by one.

Two more keys complete the set:

Copy, cut and paste #

Anything deleted with d, c or x also goes to the same place as a copy, so deleting works like cutting: dd on one line, move somewhere else, p, and the line has moved. ddp swaps a line with the one below.

Vim keeps its own clipboard, separate from the system's. To reach the system clipboard, put "+ in front: "+yy copies the line to it, "+p pastes from it. This only works when Vim was built with clipboard support. vim --version | grep clipboard tells: +clipboard means yes, -clipboard means no. On Debian and Ubuntu, the vim-gtk3 package brings a Vim that has it, even in the terminal.

Search and replace #

Search and replace happens on the command line:

:%s/old/new/g

% means the whole file, s is substitute, and g replaces every match on each line, not only the first. A c at the end (:%s/old/new/gc) makes Vim ask before each replacement, which is a good habit while learning.

Selecting text #

Moving grows the selection, and then a verb acts on it: d deletes it, y copies it, > indents it, c changes it.

Block selection has a trick worth showing a friend. Put the cursor on the first of a few lines, press Ctrl-v, move down with j to cover them, press I, type -, and press Esc. The text appears at the start of every selected line:

- milk
- eggs
- bread

Files and windows #

A small vimrc #

Vim reads its settings from ~/.vimrc. There's one catch that trips up almost everyone: without a vimrc, Vim loads a file called defaults.vim with sensible settings (syntax colors, search as you type, a few lines of margin when scrolling). The moment a personal vimrc exists, that file stops loading, and Vim suddenly looks worse. The fix is two lines at the top, straight from Vim's own help.

Code image of a starter ~/.vimrc: unlet! skip_defaults_vim and source $VIMRUNTIME/defaults.vim, then set number, relativenumber, expandtab, shiftwidth=4, softtabstop=4, ignorecase, smartcase, hlsearch, undofile and undodir=~/.vim/undo//.

Here's a small starting point:

unlet! skip_defaults_vim
source $VIMRUNTIME/defaults.vim

set number
set relativenumber
set expandtab
set shiftwidth=4
set softtabstop=4
set ignorecase
set smartcase
set hlsearch
set undofile
set undodir=~/.vim/undo//

What each part does:

Settings are best added one at a time, when they're missed. A vimrc copied from someone else is full of settings nobody remembers having.

Where to practice #

Vim ships with a tutorial. vimtutor in the terminal opens a practice file with lessons done inside Vim itself. It takes about 30 minutes, and it's the quickest way to get the basic keys into the fingers. Neovim has its own version, opened with :Tutor.

Inside Vim, :help covers everything, and it searches by topic: :help text-objects, :help iw, :help :s. The help opens inside Vim, so reading it is practice as well.

These keys also show up in more places than expected. less and man pages move with j and k and search with /, many code editors have a Vim mode, and browsers have extensions that add one. Learning them pays off outside Vim too.

Trying to learn everything at once doesn't work. Two or three new commands a week, used until the fingers know them, then a few more. After a while the keys disappear and the thinking happens in sentences: change this word, delete this paragraph, copy these three lines.

Notes

  1. ex was itself an extended version of ed, the original Unix editor from 1969, which shows one line at a time. Vim still has the whole ex inside it: every command that starts with : comes from there. ↩

  2. Vim has always been charityware. Its license asks users who like it to donate to ICCF Holland, a charity Bram supported that helps children in Uganda, and :help uganda still explains it. ↩

Original: https://pablomurad.com/vim-without-the-mystery/