[Chapter 31] Creating Custom Commands in vi
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:46:08Z

#

| Chapter 31 |

# 31. Creating Custom Commands in vi

Contents:
Why Type More Than You Have To?
Save Time and Typing with the vi map Commands
What You Lose When You Use map!
vi @-Functions
Keymaps for Pasting into a Window Running vi
Protecting Keys from Interpretation by ex
Maps for Repeated Edits
More Examples of Mapping Keys in vi
Good Stuff for Your .exrc File
Repeating a vi Keymap
Typing in Uppercase Without CAPS LOCK
Text-Input Mode Cursor Motion with No Arrow Keys
Making Cursor Keys Work in vi Text-input Mode
Don't Lose Important Functions with vi Maps: Use noremap
Fooling vi into Allowing Complex Macros
vi Macro for Splitting Long Lines

## 31.1 Why Type More Than You Have To?

Keymapping - storing complex command sequences so that they can be executed with a single keystroke - is one of my favorite timesavers. There's nothing like typing one key and watching a whole string of work take place. For repetitive edits (e.g., font changes) it's a real wrist-saver, too. In this chapter we show you how to:

- Save time by mapping keys: articles 31.2, 31.4, 31.7, and 31.8.

- Know when to map a key and when not to: article 31.3.

- Map keys like ESC and RETURN: article 31.6.

- Move around the file without leaving text-input mode: articles 31.12 and 31.13.

- Protect the text you're pasting in from another window: article 31.5.

- Put custom commands in your .exrc file: articles 31.9, 31.10, and 31.14.

- Break long lines of text: article 31.16.

- EK

30.38 Finding Your Place with Undo |  | 31.2 Save Time and Typing with the vi map Commands