## 18.9. Repeating a vi Keymap

The vi (actually, ex) command map (Section 18.2) lets you build custom vi commands. For example, the following keymap redefines the `-key` to run the vi commands o (open a newline below), ESCAPE, 72a- (add 72 dashes), and ESCAPE again:

>     :map - o^[72a-^[

So typing - draws a row of dashes below the current line. The problem is that on versions of vi I've tried, you can't add a repetition number -- that is, you can't type the command `10-` to add 10 dashed lines.

The workaround is to define another macro that calls the first macro ten times. For example, to make the `v` key draw ten rows of dashes:

>     :map v ----------

(Ugly, eh? But it works.) You might want to put the `-` `map in your` .exrc file and define "multimaps" like v while you're running vi.

-- JP

Copyright © 2003 O'Reilly & Associates. All rights reserved.