Skip to Content
Learning the vi and Vim Editors, 7th Edition
book

Learning the vi and Vim Editors, 7th Edition

by Arnold Robbins, Elbert Hannah, Linda Lamb
July 2008
Beginner
492 pages
16h
English
O'Reilly Media, Inc.
Content preview from Learning the vi and Vim Editors, 7th Edition

Extended Regular Expressions

We introduced extended regular expressions earlier in the section Extended Regular Expressions. vile provides essentially the same facilities as nvi’s extended option. This includes the POSIX bracket expressions for character classes, [[:alnum::]], with some extensions (additional classes and abbreviations), and interval expressions, such as {,10}. The syntax is somewhat different from nvi, relying on additional backslash-escaped characters:

\|

Indicates alternation: house\|home.

\+

Matches one or more of the preceding regular expression.

\?

Matches zero or one of the preceding regular expression.

\(...\)

Provides grouping for *, \+, and \?, as well as making matched subtexts available in the replacement part of a substitute command (\1, \2, etc.).

\s\S

Match whitespace and nonwhitespace characters, respectively.

\w\W

Match “word-constituent” characters (alphanumerics and the underscore, “_”) and non-word-constituent characters, respectively. For example, \w\+ would match C/C++ identifiers and keywords.[66]

\d\D

Match digits and nondigits, respectively.

\p\P

Match printable and nonprintable characters, respectively. Whitespace is considered to be printable.

vile allows the escape sequences \b, \f, \r, \t, and \n to appear in the replacement part of a substitute command. They stand for backspace, form feed, carriage return, tab, and newline, respectively. Also, from the vile documentation:

Note that vile mimics perl’s handling of \u\L\1\E instead ...

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

Learning the vi and Vim Editors, 8th Edition

Learning the vi and Vim Editors, 8th Edition

Arnold Robbins, Elbert Hannah
Vim Masterclass

Vim Masterclass

Jason Cannon
Mastering Vim

Mastering Vim

Ruslan Osipov

Publisher Resources

ISBN: 9780596529833Errata Page