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] m destination

 
Next

n[!] [[+command] filelist]

 
Number

[address] nu [count]

 
Open

[address] o [/pattern/]

 
Preserve

pre

 
Previous

prev[!]

Print

[addressp [count]
[addressP [count]

 
Put

[address] pu [char]

 
Quit

q[!]

 
Read

[address] r filename

 
Read

[address] r ! command

 
Recover

rec [filename]

 
Rewind

rew[!]

 
Right

[address] ri [count]

Set

set
set option
set nooption
set option=value
set option?

 
Shell

sh

 
Source

so filename

 
Stop

st

 
Substitute

[addr] s [/pat/repl/][opts]

 
Suspend

su

 
T (to)

[address]t destination

 
Tag

[address] ta tag

 
Unabbreviate

una word

 
Undo

u

 
Unmap

unm char

 
V (global exclude)

[address] v/pattern/[commands]

 
Version

ve

 
Visual

[address] vi [type] [count]

 
Visual

vi [+n] [filename]

 
Write

[address] w[!] [[>>]filename]

 
Write

[address] w !command

 
Wall (write all)

wa[!]

Wq (write + quit)

wq[!]

 
Wqall (write all + quit)

wqa[!]

Xit

x

 
Yank

[address] y [char] [count]

 
Z (position line)

[address] z[type] [count]

type can be one of:

+

Place line at the top of the window (default)

-

Place line at bottom of the window

.

Place line in the center of the window

^

Print the previous window

=

Place line in the center of the window and leave the current line at this line

 
! (execute command)

[address] !command

 
@ (execute register)

[address] @ [char]

 
= (line number)

[address] =

 
< > (shift)

[address< [count]
[address> [count]

 
& (repeat substitute)

[address] & [options] [count]

 
~

[address]~[count]

Like &, but with last used regular expression; for details, see Chapter 6 of Learning the vi and Vim Editors

 
Return (next line)

ENTER

 
Address

address

 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.184.90