Name

map

Synopsis

map[!] [string commands]

Define a keyboard macro named string as the specified sequence of commands. string is usually a single character, or the sequence # num, representing a function key on the keyboard. Use a ! to create a macro for input mode. With no arguments, list the currently defined macros.

Examples

:map K dwwP        Transpose two words
:map q :w^M:n^M    Write current file; go to next
:map! + ^[bi(^[ea)Enclose previous word in parentheses

Tip

vim has K and q commands, which the above aliases would hide.

Get Unix in a Nutshell, 4th 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.