Saturday, February 12, 2011

"q" macro-like action executed immediately and without specifying a register

Looked through help files and couldn't find how this is done (or if it
can be done) in vim.

Example:
If I want to append " # Great line!" to five consecutive lines, I know
that I can do it with:
q a A " # Great line!<ESC>" j q 4 @ a
(i.e. I create a macro that edits a line and moves to the next line,
and then I tell the macro to run 4 more times.)

But if I really don't want to create a macro and have to call it, is
there something like lambda for macros? I'm thinking that I'm looking
for a specific key. Referring to that key as <THE-KEY>, this is how
I'd like to be able to edit those 5 lines:
5 <THE-KEY> A " # Great line<ESC>" j <THE-KEY>

It would save 3 keystrokes, which isn't a lot; but for a short edit-
movement combo like that, it'd be pretty convenient. It'd also be nice
to not have to remember which registers are still free to assign a
macro to and to not have to add the macro register to my working
memory (brain memory not computer memory) since having to remember
something short-term like that significantly reduces mental
efficiency.

I don't know why the special key couldn't just be q when it is
preceded by [count]. (Preceding q by [count] doesn't currently have
any effect in vim, does it?)

Thanks!

Scott

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

No comments: