Skip to content

Create repeat.vim mappings with one simple "Repeatable" command

Notifications You must be signed in to change notification settings

kreskij/Repeatable.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repeatable.vim

Repeatable.vim provides a simple interface to create dot(.) repeatable mappings via tpope's repeat.vim. Add Repeatable in front of your mapping and it will be repeatable. This works with the various mapping arguments such as <silent>, <expr>, <buffer>, etc. It is designed to work exactly as you'd expect with a typical mapping, except repeatable.

Example with Repeatable.vim

Repeatable nnoremap gp p`]

Example without Repeatable.vim

nnoremap <silent> <Plug>PasteBelowCursorEnd p`]
\:call repeat#set("\<Plug>PasteBelowCursorEnd")<CR>
nmap gp <Plug>PasteBelowCursorEnd

Many users install repeat.vim as a supplement to other plugins however some may shy away from creating their own mappings due to its interface being verbose or intimidating. This plugin reduces it down to one Repeatable command which you add as a prefix to your mapping. No need to mess with custom <Plug> mappings, Repeatable.vim will take care of that for you.

Install with on-demand loading

Add the Repeatable command to on-demand loading if your plugin manager supports it.

" Example using vim-plug and on-demand loading
Plug 'tpope/vim-repeat'
Plug 'kreskij/Repeatable.vim', { 'on': 'Repeatable' }

Install without on-demand loading

If your plugin manager doesn't support on-demand loading, call the repeatable#Setup() function before any use of the Repeatable command

" Example using vim-plug and without on-demand loading
Plug 'tpope/vim-repeat'
Plug 'kreskij/Repeatable.vim'
"...
call repeatable#Setup()

Usage

Define mappings as you normally would and add Repeatable in front.

This plugin works with <expr> mappings too.

Examples

" Paste below/above and put cursor at the end of the paste
Repeatable nnoremap gp p`]
Repeatable nnoremap gP P`]

" Paste inside current line (overwrites line) (repeatable)
Repeatable nnoremap <expr> gpp '"_dd"'.v:register.'P'

About

Create repeat.vim mappings with one simple "Repeatable" command

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published