On 14/07/10 03:21, AK wrote:
On 07/13/2010 09:03 PM, nooj wrote:

Tim, Tony, and everyone -

One day I hope to remember those movement commands. Alas, learning vi is
incremental...


I understand that recording macros is efficient, but I basically never do
it. That's because I've learned to hate record mode, since I accidentally
end up in it all the time when I mistype ":q" (as "q:" or just "q"). I'm
trying to exit, and I end up at an ex command line, and for a while I
didn't
know how to get OUT of record mode... This happened for many years,
since I
only used vi when programs popped vi as a default editor. I learned to
use
it out of self defense!

Dot "." I use almost as much as cursor movement. I'm extremely familiar
with it and with the cursor movement comands, and I'd like to extend the
reach of . to include everything that happens during an insert-mode event
(typing, backspacing, arrow keys) if what it's repeating is an
insert-mode
event. Seems like there could be a flag to allow that. (I'm vaguely aware
that arrow keys in insert mode are a little weird and that they begin new
insert-mode events or something.)

And to niggle a bit, Tony, your count of the keystrokes for a macro
solution
to my problem is a little low in practice. @<letter> I count as 3
keystrokes, but the biggest underestimate comes when I do more than
three or
four repetitions. I have to physically COUNT the number of times I
want to
repeat, and to do that I hit the down key that many times, counting
them up,
and then I hit the up key to go back. THEN I have to type in the number,
@q, and see if it worked. About 25-30% of the time it doesn't (miscount,
mis-typed macro, whatever), and so I have to hit u, and repeat. This
becomes FAR more keystrokes, far more thinking, and far more time than
if I
just did one edit, one cursor movement sequence, and started hitting .
until
I got to the end.

You're doing it wrong :-). Guess on the conservative side, let's say if
you see you need about 30-35 playbacks, do: 2...@q, then see how many are
left and do e.g.: 5@@. If you guessed very close, you can do @@ and then
hit '.' as needed. In my case, I have Q defined as mapping to do @q, so
things are even easier. All in all this is one of the most indispensible
Vim commands in terms of how much work in can save you sometimes. I
can't remember how many times I'd have a few hundred lines to change and
I'd use a recording to change them in 10-15 seconds, including the time
to record.

BTW there's also a trick to visually select a block and run a recording
on all lines in it. I don't recall now how to do that but someone here
will know this if you need it.

Try (untested) :'<,'>normal @q (where the '<,'> range is inserted automatically by hitting : in Visual mode). The @q assumes that the recording was started with qq — personally I reserve register q for recorded key sequences while the 25 others are for text that I will need to insert a number of times in the course of several days, weeks, months, even years (e.g. "d is a <!DOCTYPE line for when I write HTML).


-ak


Or, to count the lines between two points (included), highlight from one to the other in linewise-visual (e.g. shift-v at one end, then scroll if necessary, and shift-click at the other end — quite fast even if it will make keyboard-only purists frown and pout), then (with 'showcmd' on) see the number of lines displayed at bottom right of the screen, at the right end of the command-line area. No need to count them on your fingers, or by saying aloud "one" j "two" j "three" j "four" j (etc.) j "one hundred and thirty-four". ;-)


Best regards,
Tony.
--
Monday is an awful way to spend one seventh of your life.

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

Reply via email to