redocommand : Execute commands from the command history.
script karma |
Rating 16/8,
Downloaded by 3189 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Ingo Karkat |
|
script type |
utility |
|
description |
DESCRIPTION
Re-executes the last / Nth ex command previously entered in command mode. An
optional pattern is used to locate the most recent matching command. This is
similar to the command-line window (q:), or navigating the command history via
<Up> and <Down>, but provides an even faster way to re-execute a command if
you remember some characters or a pattern that identifies the command line.
The redocommand itself will not be included in the command history. Global
literal replacement can be done via 'old=new' arguments.
This is modeled after the 'fc -s' command from the Posix shell (which is often
aliased to 'r').
USAGE
:[N]Redocommand (or abbreviated :R)
Execute the last / Nth ex command.
:[N]Redocommand {pattern}
Execute the last / Nth ex command that matches
{pattern}.
Settings such as 'magic' and 'ignorecase' apply.
With N=0, only the very last command from the history
is executed if it matches {pattern}; the entire
history isn't searched.
Note: If the {pattern} starts with : (and there is no
history command matching the literal ":cmd"), the
history is searched for "cmd", anchored at the
beginning. This is convenient because ":R :echo" is
more intuitive to type than ":R ^echo".
:[N]Redocommand {old}={new} [{old2}={new2} ...] [{pattern}]
Execute the last / Nth ex command (that matches
{pattern}), replacing all literal occurrences of {old}
with {new}.
:[N]RedoRepeat [{old}={new} ...] (or abbreviated :RR)
Execute the last / Nth ex command that was repeated
via :Redocommand. Any replacements done the last time
are still in effect; new replacements of {old} to
{new} can be added.
The following variants are useful when you repeatedly use command A in one
buffer and command B in another. Instead of passing different [N] values to
:RedoRepeat, just recall from the local redo history.
:[N]RedoBufferRepeat [{old}={new} ...] (or abbreviated :RB)
Like :RedoRepeat, but repeat the last / Nth ex
command repeated in the current buffer.
:[N]RedoWindowRepeat [{old}={new} ...] (or abbreviated :RW)
Like :RedoRepeat, but repeat the last / Nth ex
command repeated in the current window.
EXAMPLE
Given the following history:
:history
1 e foo.txt
2 %s/foo/\0bar/g
3 w bar.txt
:Redocommand will execute :w bar.txt
:Redocommand % will execute :%s/foo\0/bar/g
:Redocommand foo will execute :%s/foo\0/bar/g
:2Redocommand foo will execute :e foo.txt
:Redocommand b=B .txt= will execute ':w bar.txt' as :w Bar
:echo "another command"
:RedoRepeat will again execute :w Bar
:2RedoRepeat will execute :%s/foo\0/bar/g
:RedoRepeat B=F will execute :w Far
:Redocommand will execute :echo "another command"
:RedoRepeat will execute :w Far |
|
install details |
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vba.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 redocommand.vba.gz
:so %
To uninstall, use the :RmVimball command.
DEPENDENCIES
- Requires Vim 7.0 or higher.
CONFIGURATION
If you do not want the shorthand :R, :RR, :R... commands, define (e.g. in your
vimrc):
let g:redocommand_no_short_command = 1 |
|
script versions (upload new version)
Click on the package to download.
redocommand.vba.gz |
1.40 |
2012-07-20 |
7.0 |
Ingo Karkat |
ENH: Add :RedoBufferRepeat / :RB and :RedoWindowRepeat / :RW commands. These are useful when you repeatedly use command A in one buffer and command B in another. Instead of passing different [N] values to :RedoRepeat, just recall from the local redo history. |
redocommand.vba.gz |
1.30 |
2011-11-23 |
7.0 |
Ingo Karkat |
- ENH: Add :RedoRepeat command to repeat the last / Nth :Redocommand when other Ex commands (e.g. :wnext) were issued in between.
- ENH: If the {pattern} starts with : (and there is no history command matching the literal ":cmd"), the history is searched for "cmd", anchored at the beginning. This is convenient because ":R :echo" is more intuitive to type than ":R ^echo". |
redocommand.vba.gz |
1.20 |
2009-04-03 |
7.0 |
Ingo Karkat |
- Added optional [count] to repeat the Nth, not the last found match.
- Split off documentation into separate help file. Now packaging as VimBall.
- Using separate autoload script to help speed up VIM startup. |
redocommand.vim |
1.10.005 |
2009-02-11 |
7.0 |
Ingo Karkat |
Implemented ':Redocommand old=new <pattern>'. Now requiring VIM 7. |
redocommand.vim |
1.00.003 |
2008-08-04 |
6.0 |
Ingo Karkat |
Better handling of errors during execution of the command.
The redone command is added to the history.
Last version with support for VIM 6.2 - 6.4; dropped support for VIM 6.0 and 6.1. |
redocommand.vim |
0.02 |
2006-09-18 |
6.0 |
Ingo Karkat |
Initial upload |
ip used for rating: 142.132.191.50
|