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

How do I open a new line above the cursor and start typing?

Answer

O

Explanation

The O (uppercase) command opens a new blank line above the current line and places you in insert mode, ready to type. It is one of the most common ways to start inserting text in Vim.

How it works

  • O creates a new line above the cursor's current line
  • Vim enters insert mode on the new line
  • Indentation is automatically applied based on the current filetype settings

Example

Given the text with the cursor on second line:

first line
second line
third line

Pressing O and typing inserted line results in:

first line
inserted line
second line
third line

Tips

  • Use o (lowercase) to open a new line below the current line instead
  • Both o and O respect your autoindent, smartindent, and filetype indentation settings
  • Use O<Esc> to quickly insert a blank line above without typing anything
  • In visual line mode, O moves the cursor to the other end of the selection instead — this is a different behavior from normal mode

Next

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