CodeRigor

FREE LESSON

Vim basics: modes, hjkl, insert and delete

Normal vs insert mode, moving with h j k l, inserting with i a o A, deleting with x.

Vim is a modal editor. In normal mode keys are commands (move, delete, change); in insert mode they type text. You start in normal mode, and <Esc> always takes you back to it.

Turn Vim on in Settings (or the editor's status bar), then practise in the Playground. The status bar shows the current mode; Ctrl+/ opens the cheat sheet, and the coach suggests shorter keys as you go.

Moving

h j k l: the home-row arrows
h/l move one character left/right, j/k one line down/up (keeping the column).
h j k l: the home-row arrows
h/l move one character left/right, j/k one line down/up (keeping the column).

Counts multiply: 5j moves five lines down.

Inserting

Key Inserts
i before the cursor
a after the cursor "append"
I before the first non-blank character
A at the end of the line
o / O on a new line below / above

Type your text, then <Esc>.

Deleting and undoing

  • x deletes the character under the cursor (3x deletes three).
  • u undoes, Ctrl-r redoes.

The habit to build

Stay in normal mode. Go to insert mode only to type, and leave it straight away. The drills count your keystrokes against par: reach par for gold.

Watch & read

Free lectures, talks and readings that cover this skill from another angle. All resources →