Special char NOT requiring escape\ | Escape next character | ^ | Start-of-line | $ | End-of-line | . | Any char | * | 0 or more quantifier | ~ | Match last given substitute string | [...] | Match range | [^...] | Not range | & | In replacement: insert whole matched pattern |
Interpreted as regular expression operator without escaping (escape to match literal) Special char requiring escape\< | Beginning of a word | \> | End of word | \(...\) | Group | \| | Separate alternative | \_. | Any single char or end-of-line | \+ | 1 or more quantifier | \= | 0 or 1 quantifier | \? | or or 1 quantifier | \{n,m} | n to m quantifier | \{n} | n quantifier | \{n,} | at least n quantifier | \{,m} | 0 to m quantifier |
Interpreted as regular expression operators only when escaped (otherwize will be interpreted as literals). | | Useful examples:g/<pattern>/d_ | delete all lines matching pattern | s/^.*$\n// | delete empty lines | s/<pattern>/new &/ | Replace pattern by "new <whole matched pattern>" | s/<pattern>/\=@a/ | Replace pattern by content of register "a" | s/<pattern>//gn | 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: \(<pattern>\)\@<=) |
Cheatographer
www.fievel.be
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets
More Cheat Sheets by fievel