6

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?

Chetan
  • 46,743
  • 31
  • 106
  • 145

1 Answers1

7

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
  • 730,956
  • 141
  • 904
  • 1,278
  • Is there a reason that the repeat command doesn't work on navigation commands? Why this design decision? – Chetan Sep 08 '10 at 19:33
  • @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 Sep 08 '10 at 21:02