O'Reilly logo

Mastering Vim by Ruslan Osipov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Quantifiers or multis

Each character (be it a literal or a special character) or a range of characters is followed by a quantifier, or a multi in Vim terms.

For example, \w\+ will match one or more word characters, and a\{2,4} will match two to four a characters in succession (such as  aaa, for example).

Here is the list of most common quantifiers:

Symbol

Meaning

*

0 or more, greedy

\+

1 or more, greedy

\{-}

0 or more, non-greedy

\? or \=

0 or 1, greedy

\{n,m}

n to m, greedy

\{-n,m}

n to m, non-greedy

The full list of quantifiers is available through :help multi.

You may have encountered two new terms in the table given: greedy and non-greedy. Greedy search refers to trying to match as many characters ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required