Chapter 18. Creating Custom Commands in vi

Why Type More Than You Have To?

Save Time and Typing with the vi map Commands

While you’re editing, you may find that you are using a command sequence frequently, or you may occasionally use a very complex command sequence. To save yourself keystrokes — or the time it takes to remember the sequence — assign the sequence to an unused key by using the map and map! commands.

Command Mode Maps

The map command acts a lot like ab (Section 17.23) except that you define a macro for command mode instead of text-input mode. The map! command works during text-input mode; see the following list.

map x sequence

Define x as a sequence of editing commands.

unmap x

Disable the x definition.

map

List the characters ...

Get Unix Power Tools, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.