Skip to content

Instantly share code, notes, and snippets.

@atweiden
Created September 13, 2019 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atweiden/750e7ef787319340ad99eaeddd1fbae6 to your computer and use it in GitHub Desktop.
Save atweiden/750e7ef787319340ad99eaeddd1fbae6 to your computer and use it in GitHub Desktop.
Insert or append a new blank line in Vim
function! PutBlankLineAbove()
let l:count = v:count ? v:count : 1
normal m`
for i in range(1, l:count)
put! _
endfor
normal ``
execute ":normal \<Left>"
endfunction
function! PutBlankLineBelow()
let l:count = v:count ? v:count : 1
normal m`
for i in range(1, l:count)
put _
endfor
normal ``
execute ":normal \<Left>"
endfunction
nnoremap <silent> <Plug>PutBlankLineAbove :<C-U>call PutBlankLineAbove()<CR>
\ :call repeat#set("\<Plug>PutBlankLineAbove")<CR>
nnoremap <silent> <Plug>PutBlankLineBelow :<C-U>call PutBlankLineBelow()<CR>
\ :call repeat#set("\<Plug>PutBlankLineBelow")<CR>
" put blank line above current line
nmap [<space> <Plug>PutBlankLineAbove
" put blank line below current line
nmap ]<space> <Plug>PutBlankLineBelow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment