Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sisrfeng/2f9a725d4bcfaab42cb0fdd6846cfeee to your computer and use it in GitHub Desktop.
Save sisrfeng/2f9a725d4bcfaab42cb0fdd6846cfeee to your computer and use it in GitHub Desktop.
Cheatsheet for vim regex with \v specified.
Special matching strings
====
^ Start of line
$ End of line
. Any character
~ Match last given substitute string
[...] Match range
[^...] Not range
< Beginning of a word
> End of a word
_. Any single character OR EOL
Control strings
====
\ Escape next character
(...) Capture group
| Separate alternative
Replacement strings
====
& Insert entire matched pattern (equivalent to \0)
\n Insert capture group n
Quantifiers
====
* 0 or more quantifier
+ 1 or more quantifier
= 0 or 1 quantifier
? 0 or 1 quantifier
{n,m} n to m quantifier
{n} n quantifier
{n,} at least n quantifier
{,n} up to n quantifier
Lookaround
====
@<= positive lookbehind
@<! negative lookbehind
@= positive lookahead
@! negative lookahead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment