Vous êtes sur la page 1sur 1

Vim Regexp Cheat Sheet

by fievel (fievel) via cheatography.com/20997/cs/10282/


Special char NOT requiring escape

Special char requiring escape

Useful examples

Escape next character

\<

Beginning of a word

:g/<pattern> delete all lines matching pattern

Start-of-line

\>

End of word

/d_

End-of-line

\(...\)

Group

Any char

\|

Separate alternative

0 or more quantifier

\_.

Any single char or end-of-line

Match last given substitute string

\+

1 or more quantifier

[...]

Match range

\=

0 or 1 quantifier

[^...]

Not range

\?

or or 1 quantifier

&

In replacement: insert whole matched

\{n,m}

n to m quantifier

pattern

\{n}

n quantifier

\{n,}

at least n quantifier

\@<=

positive look behind

\{,m}

0 to m quantifier

\@<!

negative look behind

Interpreted as regular expression operators

\@=

positive look ahead

only when escaped (otherwize will be

\@!

negative look ahead

Interpreted as regular expression operator


without escaping (escape to match literal)

interpreted as literals).

s/^.*$\n//

delete empty lines

s/<pattern>/

Replace pattern by "new <whole

new &/

matched pattern>"

s/<pattern>/

Replace pattern by content of

\=@a/

register "a"

s/<pattern>/

Count nb occurence of pattern

/gn
Look around assertions

Must follow a group matching what to look


behind or ahead (ex: \(<pattern>\)\@<=)

By fievel (fievel)

Published 19th December, 2016.

Sponsored by Readability-Score.com

cheatography.com/fievel/

Last updated 19th December, 2016.

Measure your website readability!

www.fievel.be

Page 1 of 1.

https://readability-score.com

Vous aimerez peut-être aussi