On Mar 23, 11:24 pm, E <[email protected]> wrote:
> Can a macro be executed while in insert mode?
>
[Snip]
>
> Let MACRO (@r) have resulting action that
> can be represented by this kind of:
> ^{IF "$foo[Number adjacent to EOL]"<>"" } or
> "insert the desired additional text on each line with the number that
> is on the
> end of each line being appended to the second word on each line"
>
So, you already have a macro that will do what you want to a single
line? That's what it seems like you're saying. It seems like you're
asking, "how do I run this macro I already have, on multiple lines"?
> ^v "Control+v" Mode is
> command.
> ____________________________
> -VISUAL BLOCK-
>
[Snip]
> I "Shift+i" Mode becomes
> insert
> ----------------------------------------------
> -INSERT-
>
> Now what? How do I indicate that I want to execute
> the macro stored in @r without having to press <ESC>?
> ^vGI{@r}
Here, it looks like you are trying to run your pre-existing macro on a
bunch of lines, in the same way that you would insert text on a bunch
of lines. I admit this makes some sense conceptually.
Nevertheless, if I am correct, and your real goal is to run a macro on
a bunch of lines, and you are trying to accomplish this by going into
visual block mode and hitting 'I' similar to what you would do when
inserting text, then you are doing it wrong.
If you already have a macro in register 'r' which does what you want
on a single line, then you should execute it on several lines as
follows:
1. select the lines you wish in any visual mode (not necessarily
visual block, but this will work; I normally use linewise visual)
2. Hit ':' to enter Ex mode and automatically insert a range of '<,'>
(last visual selection)
3. Run the macro on all the selected lines by executing :'<,'>normal!
Alternatively, you could include a j at the end of your 'r' macro to
go to the next line, and simply repeat the macro for the number of
lines needed:
7@r
If you have an existing macro which works on a single line, it is easy
to modify it to also move to the next line, just do:
qRjq
Note the capital letter R, which tells Vim to record to 'r' but append
to rather than overwrite the contents.
--
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