Supported Metacharacters

Table 56 through Table 60 list the metacharacters and metasequences supported by vi. For expanded definitions of each metacharacter, see "Regex Metacharacters, Modes, and Constructs.”

Table 1-56. vi character representation

Sequence

Meaning

Vim only

 

\b

Backspace, \x08.

\e

Escape character, \x1B.

\n

Newline, \x0A.

\r

Carriage return, \x0D.

\t

Horizontal tab, \x09.

Table 1-57. vi 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

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

\a

Letter character, [a-zA-z].

\A

Nonletter 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

Nondigit character, [^0-9].

\s

Whitespace character, [ \t].

\S

Nonwhitespace character, [^ \t].

\x

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

\X

Nonhex digit, [^a-fA-F0-9].

\o

Octal digit, [0-7].

\O

Nonoctal digit, [^0-7].

\l

Lowercase letter, [a-z].

\L

Nonlowercase letter, [^a-z].

\u

Uppercase letter, [A-Z].

\U

Nonuppercase letter, [^A-Z].

\i

Identifier character defined by isident.

\I

Any nondigit identifier character.

\k

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

\K

Any nondigit keyword character.

\f

Filename character defined by isfname. Operating system-dependent. ...

Get Regular Expression Pocket Reference, 2nd 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.