*visualrepeat.txt* Repeat command extended to visual mode. VISUALREPEAT by Ingo Karkat *visualrepeat.vim* description |visualrepeat-description| usage |visualrepeat-usage| installation |visualrepeat-installation| integration |visualrepeat-integration| limitations |visualrepeat-limitations| known problems |visualrepeat-known-problems| todo |visualrepeat-todo| history |visualrepeat-history| ============================================================================== DESCRIPTION *visualrepeat-description* This plugin defines repetition of Vim built-in normal mode commands via |.| for visual mode. Additionally, it offers functions like the popular repeat.vim plugin that allow mappings to be repeated in visual mode, too. VISUAL MODE REPETITION * This extends the built-in normal mode repeat |.| to visual mode. VISUAL MODE MAPPING REPETITION * Like with repeat.vim for normal mode, visual mode mappings can register a mapping to be used for visual mode repetition. Likewise, normal mode mappings can (in addition to the repeat.vim registration of a normal mode mapping) register a visual mode mapping with visualrepeat.vim that will be repeated in visual mode. Operator-pending mappings end with |g@| and repeat naturally; i.e. Vim re-applies the 'opfunc' on the equivalent text (but at the current cursor position). But without a call to repeat#set(), it is impossible to repeat this operator-pending mapping to the current visual selection. Plugins cannot call repeat#set() in their operator-pending mapping, because then Vim's built-in repeat would be circumvented, the full mapping ending with g@ would be re-executed, and the repetition would then wait for the {motion}, what is not wanted. Therefore, this plugin offers a separate visualrepeat#set() function that can be invoked for operator-pending mappings. It can also be invoked for normal-mode mappings that have already called repeat#set(), and may override that mapping with a special repeat mapping for visual mode repeats. Together with the remapped {Visual}. command, this allows repetition - similar to what the built-in Vim commands do - across normal, operator-pending and visual mode. SOURCE * - Based on vimtip #1142, Repeat last command and put cursor at start of change http://vim.wikia.com/wiki/Repeat_last_command_and_put_cursor_at_start_of_change - The client interface and implementation has been based on repeat.vim (vimscript #2136) by Tim Pope. RELATED WORKS * - repeat.vim (vimscript #2136) has been the basis for this plugin and should be used in conjunction with visualrepeat.vim. (Otherwise, you'd have visual mode repeat, but no repeat in normal mode.) ============================================================================== USAGE *visualrepeat-usage* *v_.* {Visual}. Repeat last change in all visually selected lines. - characterwise: Start from cursor position. - linewise: Each line separately, starting from the current column (usually the first in this mode). - blockwise: Only the selected text. This is implemented by temporarily duplicating the selection to separate lines and repeating over those, starting from the first column. Note: If the last normal mode command included a {motion} (e.g. g~e), the repetition will also move exactly over this {motion}, NOT the visual selection! It is thus best to repeat commands that work on the entire line (e.g. g~$). ============================================================================== INSTALLATION *visualrepeat-installation* This script is packaged as a |vimball|. If you have the "gunzip" decompressor in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress the archive first, e.g. using WinZip. Inside Vim, install by sourcing the vimball or via the |:UseVimball| command. > vim visualrepeat*.vmb.gz :so % To uninstall, use the |:RmVimball| command. DEPENDENCIES *visualrepeat-dependencies* - Requires Vim 7.0 or higher. - repeat.vim (vimscript #2136) plugin (highly recommended) - |ingo-library.vim| plugin (vimscript #4433), version 1.013 or higher; optional, for blockwise repeat only ============================================================================== INTEGRATION *visualrepeat-integration* This plugin is meant to be used together with repeat.vim. This plugin has helper functions that plugins with cross-repeat functionality can use in their normal mode repeat mappings of repeated visual mode mappings. With this, you save work and allow for a consistent user experience. Define your normal mode repeat mapping like this: > nnoremap (MyPluginVisual) \ :execute 'normal!' visualrepeat#reapply#VisualMode(0) \call MyPlugin#Operator('visual', "\Plug>(MyPluginVisual)") If your plugin uses a passed [count] (i.e. the count is not only used to determine the text area the mapping is applied to), you need to define a mapping: > vnoremap (ReapplyRepeatCount) visualrepeat#reapply#RepeatCount() and apply the function followed by the mapping like this: > nnoremap