Created
September 13, 2019 00:15
-
-
Save atweiden/750e7ef787319340ad99eaeddd1fbae6 to your computer and use it in GitHub Desktop.
Insert or append a new blank line in Vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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