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

How do I add blank lines above or below the current line using vim-unimpaired?

Answer

[<Space> and ]<Space>

Explanation

vim-unimpaired (by Tim Pope) provides paired bracket mappings for dozens of common operations. Two of its most useful are [<Space> and ]<Space>, which insert blank lines above or below the current line without moving the cursor or entering Insert mode.

How it works

  • [<Space> — insert one blank line above the current line
  • ]<Space> — insert one blank line below the current line
  • Both commands accept a count: 3]<Space> inserts three blank lines below

Unlike pressing O<Esc> (enter insert mode above and immediately exit), these mappings leave you in Normal mode and keep the cursor on the original line, making them composable with . for repeating.

Example

Given:

foo
bar    ← cursor here
baz

After ]<Space>:

foo
bar    ← cursor stays here

baz

After [<Space> on the same line:

foo

bar    ← cursor stays here

baz

Tips

  • [e and ]e move the current line up or down (like :m but with a count and dot-repeat support)
  • [f and ]f navigate to the previous/next file in the same directory
  • [b and ]b cycle through the buffer list (:bprev / :bnext)
  • Install via any plugin manager: tpope/vim-unimpaired
  • To get the same blank-line behavior without the plugin, map it manually: nnoremap [<Space> O<Esc> / nnoremap ]<Space> o<Esc>

Next

How do I right-justify a line of text to a specific width using a built-in Vim command?