O'Reilly logo

Unix Power Tools, 3rd Edition by Mike Loukides, Tim O'Reilly, Shelley Powers, Jerry Peek

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required