Skip to content

soheilghafurian/vim-normal-insert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-normal-insert

Insert blank lines and single characters without leaving normal mode.

Features

  • 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>o inserts 3 blank lines, 3<leader>i inserts 3 copies of a character)
  • Dot-repeat via vim-repeat, with multiplier (3<leader>o then 2. inserts 6 more)
  • Cursor position preserved after every operation

Installation

Plug 'soheilghafurian/vim-normal-insert'
Plugin 'soheilghafurian/vim-normal-insert'
cd ~/.vim/bundle
git clone https://github.com/soheilghafurian/vim-normal-insert.git

Manual

Copy plugin/normal_insert.vim into ~/.vim/plugin/.

Usage

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

vim-repeat

Dot-repeat support requires vim-repeat. Without it the plugin works normally but . will not repeat the operation.

Tests

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.vader
vim -Nu <(cat <<'EOF'
filetype off
set rtp+=~/.vim/bundle/vader.vim
set rtp+=.
filetype plugin indent on
EOF
) +Vader! test/test_char_insert.vader

License

Distributed under the same terms as Vim itself. See :help license.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors