I use a mapping for that:
" Quickly insert an empty new line without entering insert mode
nnoremap <Leader>o o<Esc>
nnoremap <Leader>O O<Esc>
This way you can insert a line under your cursor with <Leader>o
and one on the previous line with <Leader>O
.
Note: One could argue that it requires as many keystrokes as o<Esc>
but hopefully you choosed your leader to make this kind of mapping easy. Also I'm really not sure there is a built-in way to do this.
Edit I ended up using these mappings instead because there were some edge cases where the new line contained unwanted whitespaces characters:
nnoremap <Leader>o o<Esc>0"_D
nnoremap <Leader>O O<Esc>0"_D
Also, the plugin vim-unimpaired does it a bit differently:
function! BlankUp(count) abort
put!=repeat(nr2char(10), a:count)
']+1
silent! call repeat#set("\<Plug>unimpairedBlankUp", a:count)
endfunction
function! BlankDown(count) abort
put =repeat(nr2char(10), a:count)
'[-1
silent! call repeat#set("\<Plug>unimpairedBlankDown", a:count)
endfunction
nnoremap <Plug>unimpairedBlankUp :call BlankUp(v:count1)<CR>
nnoremap <Plug>unimpairedBlankDown :call BlankDown(v:count1)<CR>
The difference is that my version puts your cursor on the newly created line whereas Pope's version adds the line but leave your cursor on the same place. He also make uses his vim-repeat plugin so that the .
command works better.