Mission 07 / 52• Insert Like a Pro
Opening New Lines
In standard text editors, creating a new line requires navigating to the end of the line and hitting Enter, or going to the start and hitting Enter then up arrow.
Vim has first-class commands to open empty lines from anywhere on the current line.
Opening lines
- oopen a new line BELOW the current line and enter insert mode
- Oopen a new line ABOVE the current line and enter insert mode
Press Enter to start
1function processOrder(order) {2 validateOrder(order);3 shipOrder(order);4}Put your cursor on `validateOrder`. Press `o` to create a blank line right underneath and start typing `logOrder(order);`.
Press `esc`, then press `O` to insert a comment right above without manually moving your cursor.
Tip: Lowercase `o` opens down (below); uppercase `O` opens up (above).
Now it's your turn!
0 / 4 tasks complete0.0s / 30s par0 / 57 par
Practice this lesson's commands. Each task checks your technique and the result, not just your cursor position. Take your time.
Task 1: Add // prepare above with O, preserving indentation. Return to normal mode.
Expected result
// prepare validate(); ship();
Show hint
Press O, type // prepare, then Escape.
Press Enter to start
1 validate();2 ship();jkscroll•ggGtop/bottom•Tabnext example•Enterstart•qstop•Ctrl+kCtrl+jprev/next