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
[eand]emove the current line up or down (like:mbut with a count and dot-repeat support)[fand]fnavigate to the previous/next file in the same directory[band]bcycle 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>