How do I open a new line below the cursor and start typing?
Answer
o
Explanation
The o command opens a new line below the current line and places you in insert mode, ready to type. It is one of the most frequently used commands for adding new content to a file.
How it works
ocreates a blank line below the current line- The cursor moves to the new line
- Vim enters insert mode immediately
- Indentation is automatically applied based on your filetype and indent settings
Example
Given the text with the cursor on first line:
first line
third line
Pressing o opens a new line below and enters insert mode. Type second line and press <Esc> to get:
first line
second line
third line
Tips
- Use
O(uppercase) to open a new line above the current line instead - Use
5oto insert the same text on 5 new lines (type your text, press<Esc>, and Vim repeats it) - Unlike pressing
A<CR>, theocommand works regardless of where the cursor is on the line - In programming files with
autoindentorsmartindentenabled, the new line automatically matches the indentation level of the surrounding code - Combine with
.to repeat — after usingoto add a line of text, press<Esc>, move to another location, and press.to insert the same text on a new line there