" Vimball Archiver by Charles E. Campbell UseVimball finish autoload/repeatableMapping.vim [[[1 558 " repeatableMapping.vim: Set up mappings that can be repeated via repeat.vim. " " DEPENDENCIES: " - repeat.vim (vimscript #2136) plugin (optional) " - visualrepeat.vim (vimscript #3848) plugin (optional) " - ingo-library.vim plugin (optional) " " Copyright: (C) 2008-2020 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat let s:save_cpo = &cpo set cpo&vim " Support normal mode repeat of visual mode mapping (through only repeat.vim) " when visualmode.vim isn't installed. function! s:VisualMode() let l:keys = '1v' silent! let l:keys = visualrepeat#reapply#VisualMode(1) return l:keys endfunction vnoremap (ReapplyRepeatCount) visualrepeat#reapply#RepeatCount() function! s:ReapplyVisualMode() let s:count = v:count if visualmode() ==# 'V' " If the command to be repeated was in linewise visual mode, the repeat " command is invoked for each individual line. Thus, we only need to " select the current line. return 'V' elseif getpos('.') == getpos("'<") || getpos('.') == getpos("'>") return 'gv' else return '1v' . (&selection ==# 'exclusive' ? ' ' : '') endif endfunction function! s:ReapplyGivenCount() return (s:count ? s:count : '') endfunction vnoremap (ReapplyGivenCount) ReapplyGivenCount() " This gets triggered when repeating visual mode mappings that do not have " defined a cross-repeatable normal mode mapping. Instead, through something " like a simple :xmap . or the visualrepeat.vim plugin, the original visual mode " mapping is re-applied, using this (ReenterVisualMode) as a bridge from " normal-mode back to visual mode. " Use :normal first to swallow the passed [count], so that it doesn't affect the " V / gv / 1v commands that are returned by " s:ReapplyVisualMode(). Then put back the [count] via (ReapplyGivenCount) " so that it applies to the repeated mapping. Note that without cross-repeat, a " normal mode repeat of the visual mode mapping will work, but always on the " current line / same-size selection with the original [count]. This is " different from cross-repeat, where one can specify [count] lines / times the " original selection, with the original repeat. nnoremap