Learn Vim / How to Insert a New Line in Vim

How to Insert a New Line in Vim

The answerPress o to open a new line below the cursor (or O for above) — both drop you into insert mode.

Try it on a real buffer

Step 2 is missing! With the cursor on line 1, press o to open a new line below, type exactly “Step 2: Whisk until smooth”, then Esc.

Step 1: Crack two eggs into a bowl
Step 3: Serve immediately

Canonical solution: o, type the step, Esc · target: 28 keystrokes — the fewest that solve it (every keypress counts).

Why it works

o opens a new line below the cursor and puts you in insert mode. O (capital) opens a line above instead.

Variations

KeysWhat it does
onew line below, enter insert mode
Onew line above, enter insert mode
▶ live vim buffertarget 28 keystrokes
Step 2 is missing! With the cursor on line 1, press o to open a new line below, type exactly “Step 2: Whisk until smooth”, then Esc.

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “The missing step” mission takes about a minute.

Sign in free to practice →

Keep going