> I sometimes want to repeat a sequence of operations
> like I would repeat a single command.
[cut]
> The obvious choice to repeat multiple operations is to record
> a macro (for example:  qq02r/q ), and replay it with @q.
> Unfortunately, '.' after @q only replays the last action
> within the macro, not the whole macro execution.
> So I have to repeatedly type two awkward keys (@q) instead
> of being able to use the dot command to repeat the whole
> sequence of operations.

Once you have run a macro once (with "@q"), you can re-run it
with "@@" which is considerably easier to type.

Additionally, if your macro moves you to the next point where
you'd issue the macro again, and you know you want to repeat it N
times, you can prefix the macro-execution with a count, such as

        [EMAIL PROTECTED]

will run the "q" macro 23 times.

You can read more if you need at

        :help @@

Alternatively, problems can often be rephrased in terms of an Ex
command that uses the ":%s" or ":g"/":v" to perform changes
across the entire file.  While you didn't want to focus on your
commenting example, one could do something like

        :g/foo/s!^!//

which would comment out every line containing "foo".  By changing
your thinking to exploit these commands, sometimes you can get
easy consistent changes without having to manually touch each bit
with a macro.  Knowing both macros and obscure corners of Ex, I
find I don't record macros all that often (maybe once every month
or so) but tend to use automated Ex commands to surgically alter
my text.

Hope this helps or at least gives you a couple new ideas,

-tim




Reply via email to