Insert blank lines and single characters without leaving normal mode.
- Insert one or more empty lines below the current line
- Insert one or more empty lines above the current line
- Insert a single character before the cursor (with count support)
- Insert a single character after the cursor (with count support)
- Count support (
3<leader>oinserts 3 blank lines,3<leader>iinserts 3 copies of a character) - Dot-repeat via vim-repeat, with multiplier (
3<leader>othen2.inserts 6 more) - Cursor position preserved after every operation
Plug 'soheilghafurian/vim-normal-insert'Plugin 'soheilghafurian/vim-normal-insert'cd ~/.vim/bundle
git clone https://github.com/soheilghafurian/vim-normal-insert.gitCopy plugin/normal_insert.vim into ~/.vim/plugin/.
The plugin exposes <Plug> mappings. Add bindings to your .vimrc:
nmap <silent> <leader>o <Plug>(NormalInsertEmptyBelow)
nmap <silent> <leader>j <Plug>(NormalInsertEmptyAbove)
nmap <silent> <leader>i <Plug>(NormalInsertCharBefore)
nmap <silent> <leader>a <Plug>(NormalInsertCharAfter)| Keystrokes | Effect |
|---|---|
<leader>o |
Insert one blank line below |
3<leader>o |
Insert three blank lines below |
<leader>j |
Insert one blank line above |
5<leader>j |
Insert five blank lines above |
<leader>i then type x |
Insert x before the cursor |
3<leader>i then type x |
Insert xxx before the cursor |
<leader>a then type x |
Insert x after the cursor |
3<leader>a then type x |
Insert xxx after the cursor |
. |
Repeat the last insert with the same count |
2. |
Repeat the last insert, multiplying the original count by 2 |
Dot-repeat support requires vim-repeat.
Without it the plugin works normally but . will not repeat the operation.
Tests use vader.vim:
vim -Nu <(cat <<'EOF'
filetype off
set rtp+=~/.vim/bundle/vader.vim
set rtp+=.
filetype plugin indent on
EOF
) +Vader! test/test_empty_lines.vadervim -Nu <(cat <<'EOF'
filetype off
set rtp+=~/.vim/bundle/vader.vim
set rtp+=.
filetype plugin indent on
EOF
) +Vader! test/test_char_insert.vaderDistributed under the same terms as Vim itself. See :help license.