vimtricks.wiki Concise Vim tricks, one at a time.

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

  • o creates 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 5o to insert the same text on 5 new lines (type your text, press <Esc>, and Vim repeats it)
  • Unlike pressing A<CR>, the o command works regardless of where the cursor is on the line
  • In programming files with autoindent or smartindent enabled, the new line automatically matches the indentation level of the surrounding code
  • Combine with . to repeat — after using o to add a line of text, press <Esc>, move to another location, and press . to insert the same text on a new line there

Next

How do I edit multiple lines at once using multiple cursors in Vim?