views:

29

answers:

1

How do I repeat a navigation command in vi?

For example, I execute the command 20j which moves the cursor down 20 lines, and I tried hitting . to repeat that command, but it says "No command to repeat".

P.S. Also, what command goes to the next page in a document?

A: 

There isn't a shortcut to repeat the last navigation command - you have to retype it, or set up some sort of shortcut of your own (:map or similar).

Page up (back) is Control-B; page down (forward) is Control-F. Half-pages are Control-U (up) and Control-D (down).

Jonathan Leffler
Is there a reason that the repeat command doesn't work on navigation commands? Why this design decision?
Chetan
@Chetan: because the change commands are usually more complex. Besides, if you're searching, you can use 'n' or 'N' to jump to the next or previous match - which is a short cut for searches, I suppose. For my work, I most frequently use the n's, or jumps such as '`[[`' or '`]]`' to find the start of a function, or '`{`' or '`}`' to find paragraphs. Or I use a map to coordinate both the change position and change data.
Jonathan Leffler