Supported Metacharacters

Table 1-36 through Table 1-40 list the metacharacters and metasequences supported by vi. For expanded definitions of each metacharacter, see Section 1.2.1.

Table 1-36. Character representation

Sequence

Meaning

Vim only



Backspace, x08.

e

ESC character, x1B.

Newline, x0A.

Carriage return, x0D.

Horizontal tab, x09.

Table 1-37. Character classes and class-like constructs

Class

Meaning

[...]

Any character listed or contained within a listed range.

[^...]

Any character that is not listed or contained within a listed range.

[:class:]

POSIX-style character class valid only within a character class.

.

Any character except newline (unless /s mode).

Vim only

w

Word character, [a-zA-z0-9_].

W

Non-word character, [^a-zA-z0-9_].

a

Letter character, [a-zA-z].

A

Non-letter character, [^a-zA-z].

h

Head of word character, [a-zA-z_].

H

Not the head of a word character, [^a-zA-z_].

d

Digit character, [0-9].

D

Non-digit character, [^0-9].

s

Whitespace character, [ ].

S

Non-whitespace character, [^ ].

x

Hex digit, [a-fA-F0-9].

X

Non-hex digit, [^a-fA-F0-9].

o

Octal digit, [0-7].

O

Non-octal digit, [^0-7].

l

Lowercase letter, [a-z].

L

Non-lowercase letter, [^a-z].

u

Uppercase letter, [A-Z].

U

Non-uppercase letter, [^A-Z].

i

Identifier character defined by isident.

I

Any non-digit identifier character.

k

Keyword character defined by iskeyword, often set by language modes.

K

Any non-digit keyword character.

f

Filename character defined by isfname. Operating system dependent.

F

Any non-digit filename character.

p

Printable character defined by isprint, usually x20-x7E.

P

Any non-digit printable character.

Table 1-38. Anchors and zero-width tests

Sequence

Meaning

^

Start of a line when appearing first in a regular expression; otherwise, it matches itself.

$

End of a line when appearing last in a regular expression; otherwise, it matches itself.

<

Beginning of word boundary, (i.e., a position between a punctuation or space character and a word character).

>

End of word boundary.

Table 1-39. Mode modifiers

Modifier

Meaning

:set ic

Turns on case-insensitive mode for all searching and substitution.

:set noic

Turns off case-insensitive mode.

u

Force next character in a replacement string to uppercase.

l

Force next character in a replacement string to lowercase.

U

Force all following characters in a replacement string to uppercase.

L

Force all following characters in a replacement string to lowercase.

E or e

Ends a span started with U or L.

Table 1-40. Grouping, capturing, conditional, and control

Sequence

Meaning

(...)

Group subpattern and capture submatch into 1,2,...

n

Contains the results of the nth earlier submatch. Valid in both a regex pattern or a replacement string.

&

Evaluates to the matched text when used in a replacement string.

*

Match 0 or more times.

Vim only

+

Match 1 or more times.

=

Match 1 or 0 times.

{n}

Match exactly n times.

{n,}

Match at least n times.

{,n}

Match at most n times.

{x,y}

Match at least x times, but no more than y times.

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

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