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

ex Commands

This section summarizes the ex commands used from the colon prompt in vi.

Command Syntax

:[address]command[options]

Address Symbols

Address

Includes

1,$

All lines in the file

x,y

Lines x through y

x;y

Lines x through y, with current line reset to x

0

Top of file

.

Current line

n

Absolute line number n

$

Last line

%

All lines; same as 1,$

x-n

n lines before x

x+n

n lines after x

-[n]

One or n lines previous

+[n]

One or n lines ahead

x

Line marked with x (single quote)

’ ’

Previous mark (two single quotes)

/pat/ or ?pat?

Ahead or back to the line where pat matches

Command Option Symbols

Symbol

Meaning

!

A variant form of the command

count

Repeat the command count times

file

Filename: % is current file, # is previous file

Alphabetical List of Commands

The following table of ex commands covers both standard ex commands and selected commands specific to Vim. Commands covered in Vim—vi Improved are omitted here.

Full nameCommandVim only
Abbrev

ab [string text]

 
Append

[addressa[!] text .

 
Args

ar

 
Args

args files …

Bdelete

[num] bd[!] [num]

Buffer

[num] b[!] [num]

Buffers

[num] buffers[!]

Center

[address] ce [width]

Change

[address]c[!] text .

 
Chdir

cd directory

 
Copy

[address] co destination

 
Delete

[address] d [buffer]

 
Edit

e [!][+n] [filename]

 
File

f [filename]

 
Global

[address]g[!]/pattern/[commands]

 
Insert

[address]i[!] text .

 
Join

[address]j[!][count]

 
K (mark)

[address] k char

 
Left

[address] le [count]

List

[address] l [count]

 
Map

map char commands

 
Mark

[address] ma char

 
Mkexrc

mk[!] file

Move

[address ...

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