Repeating a vi Keymap

The vi (actually, ex) command map () lets you build custom vi commands. For example, this map redefines the - key to run the vi commands o (open a new line below), ESCAPE, a- (add 75 dashes), and ESCAPE again:

:map - o^[75a-^[

So typing - draws a row of dashes below the current line. The problem is that on many versions of vi, you can't add a repetition number - that is, you can't type the command - 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 "multi-maps" like v while you're running vi.

- JP