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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.