On 07/13/2010 01:54 AM, Tony Mechelynck wrote:
On 13/07/10 07:22, nooj wrote:
>
>>> Is there a way to repeat the last cursor movement? Dot (.) repeats
last
> edit,
>>> is there an analog for motion, so that, for example, if I press zj to
>>> move down
>>> a fold I can just hit some other key to repeat that?
>
>> You can always record macros, and bind a key to playback a macro.
>
> This isn't as good. Sometimes you want to repeat something only one
or two
> times, and recording the macro and playing it back can take more
keystrokes
> than repeating the movement would. Instead, cleverly positioning the
cursor
> after an edit allows one to just keep hitting dot (.) for each
repetition.
>
> I used a version of vi/vim/gvim which did this, and I have no idea what
> version it was or system it ran on.
>
>
Recording the macro means doing it once, plus a q and register letter
before and a q afterwards i.e. n+3 keystrokes.
Replaying it once is @ <letter> i.e. 2 keystrokes
Replaying it 2 to 9 times is <digit> @ <letter> i.e. 3 keystrokes.
Replaying it 10 to 99 times is 4 keystrokes.
For this to be disadvantageous, your sequence to be repeated must be
no more than 5 keystrokes if you do it twice (record once, replay once),
no more than 3 if you do it three times, etc. For so short a sequence,
you can afford to repeat it with no recording.
Hitting the dot repeats the last _change_ in Vim, not including
ex-commands. Also the last yank if you are in 'compatible' mode (or if
'cpoptions' includes the y flag; but "repeating a yank" means that the
text previously yanked is "forgotten" from the yank register — not very
useful). @: repeats the last ex-command. n repeats the last search.
Other than that, I don't think there's a built-in keystroke.
Best regards,
Tony.
It also might make sense to make mappings for a recording to a register
and for playing back that register. Then recording and playback
will take 2 and 1 letters respectively. It's a very common usage to
repeat a few operations and simplifying recording/playback can lead to
recording being used much more frequently. I personally use "qq" to
record because it's nearly as easy as a single command and Q to play
back the register. I use it all the time! -ak
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php