Skip to Main Content
vi and Vim Editors Pocket Reference, 2nd Edition
book

vi and Vim Editors Pocket Reference, 2nd Edition

by Arnold Robbins
January 2011
Intermediate to advanced content levelIntermediate to advanced
94 pages
1h 52m
English
O'Reilly Media, Inc.
Content preview from vi and Vim Editors Pocket Reference, 2nd Edition

Input Mode Shortcuts

vi provides two ways to decrease the amount of typing you have to do: abbreviations and maps.

Word Abbreviation

:ab abbr phrase

Define abbr as an abbreviation for phrase.

:ab

List all defined abbreviations.

:unab abbr

Remove definition of abbr.

Command and Input Mode Maps

:map x sequence

Define character(s) x as a sequence of editing commands.

:unmap x

Disable the sequence defined for x.

:map

List the characters that are currently mapped.

:map! x sequence

Define character(s) x as a sequence of editing commands or text that will be recognized in insert mode.

:unmap! x

Disable the sequence defined for the insert mode map x.

:map!

List the characters that are currently mapped for interpretation in insert mode.

For both command and insert mode maps, the map name x can take several forms:

One character

When you type the character, vi executes the associated sequence of commands.

Multiple characters

All the characters must be typed within one second. The value of notimeout changes the behavior.

# n

Function key notation: a # followed by a digit n represents the sequence of characters sent by the keyboard’s function key number n.

To enter characters such as Escape (^[) or carriage return (^M), first type CTRL-V (^V).

Executable Buffers

Named buffers provide yet another way to create “macros”—complex command sequences you can repeat with a few keystrokes. Here’s how it’s done:

  1. Type a vi command sequence or an ex command preceded by a colon; return to command mode.

  2. Delete the text into a named buffer. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro Vim

Pro Vim

Mark McDonnell
Learning the vi and Vim Editors, 7th Edition

Learning the vi and Vim Editors, 7th Edition

Arnold Robbins, Elbert Hannah, Linda Lamb

Publisher Resources

ISBN: 9781449303082Errata Page