Show Menu

Vim Regexp Cheat Sheet by

Special char NOT requiring escape

Escape next character
Any char
0 or more quantifier
Match last given substitute string
Match range
Not range
In replac­ement: insert whole matched pattern
Interp­reted as regular expression operator without escaping (escape to match literal)

Special char requiring escape

Beginning of a word
End of word
Separate altern­ative
Any single char or end-of­-line
1 or more quantifier
0 or 1 quantifier
or or 1 quantifier
n to m quantifier
n quantifier
at least n quantifier
0 to m quantifier
Interp­reted as regular expression operators only when escaped (otherwize will be interp­reted as literals).

Useful examples

delete all lines matching pattern
delete empty lines
s/<­pat­ter­n>/new &/
Replace pattern by "new <whole matched patter­n>"
Replace pattern by content of register "­a"
Count nb occurence of pattern

Look around assertions

positive look behind
negative look behind
positive look ahead
negative look ahead
Must follow a group matching what to look behind or ahead (ex: \(<­pat­ter­n>­\)\@­<=)

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          VI Editor Cheat Sheet
          Vim NERDTree Cheat Sheet
          cVim Keyboard Shortcuts

          More Cheat Sheets by fievel

          English Irregular Verbs Cheat Sheet
          Awesome Window Manager 3.x Cheat Sheet