sponsor Vim development Vim logo Vim Book Ad

visualrepeat : Repeat command extended to visual mode.

 script karma  Rating 41/11, Downloaded by 1201  Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
script type
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.

This extends the built-in normal mode repeat . to visual mode.

Like with repeat.vim for normal mode, visual mode mappings can register a
<Plug> 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
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

- Based on vimtip #1142, 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.

- 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.)

{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~$).
install details
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.

- 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

This plugin is meant to be used together with repeat.vim.

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
visualrepeat-1.30.vmb.gz 1.30 2013-11-15 7.0 Ingo Karkat - ENH: When repeating over multiple lines / a blockwise selection, keep track of added or deleted lines, and only repeat exactly on the selected lines. Thanks to Israel Chauca for sending a patch!
- When a repeat on a blockwise selection has introduced additional lines, append those properly indented instead of omitting them.
- With linewise and blockwise repeat, set the change marks '[,'] to the changed selection. With the latter, one previously got "E19: Mark has invalid line number" due to the removed temporary range.
visualrepeat-1.20.vmb.gz 1.20 2013-11-14 7.0 Ingo Karkat - ENH: Implement blockwise repeat through temporarily moving the block to a temporary range at the end of the buffer, like the vis.vim plugin. This feature requires the ingo-library. *** You need to separately install ingo-library (vimscript #4433) version 1.013 (or higher)! ***
visualrepeat-1.10.vmb.gz 1.10 2013-09-05 7.0 Ingo Karkat - Check for existence of actual visual mode mapping; do not accept a select mode mapping, because we're applying it to a visual selection.
- Pass through a [count] to the :normal . command.
- Add visualrepeat#reapply#VisualMode() and visualrepeat#reapply#RepeatCount() helper functions that plugins can use in their normal mode repeat mappings of repeated visual mode mappings.
- Minor: Make substitute() robust against 'ignorecase'.
- ENH: Use the current cursor virtual column when repeating in linewise visual mode. Inspired by http://stackoverflow.com/questions/18610564/vim-is-possible-to-use-dot-command-in-visual-block-mode
- Abort further commands on error by using echoerr inside the mapping.
visualrepeat-1.03.vmb.gz 1.03 2013-02-21 7.0 Ingo Karkat REGRESSION: Fix in 1.02 does not repeat recorded register when the mappings in repeat.vim and visualrepeat.vim differ.
visualrepeat-1.02.vmb.gz 1.02 2012-12-27 7.0 Ingo Karkat BUG: "E121: Undefined variable: g:repeat_sequence" when using visual repeat of a mapping using registers without having used repeat.vim beforehand.
visualrepeat.vba.gz 1.01 2012-04-05 7.0 Ingo Karkat FIX: Avoid error about undefined g:repeat_reg when (a proper version of)
repeat.vim isn't available.
visualrepeat.vba.gz 1.00 2011-12-14 7.0 Ingo Karkat Initial upload
ip used for rating:

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
OSDN.net Logo