Examples
Example 1-35. Simple search in vi
Find spider-man, Spider-Man, Spider Man
/[Ss]pider[- ][Mm]an
Example 1-36. Simple search in Vim
Find spider-man, Spider-Man, Spider Man, spiderman, SPIDER-
MAN, etc.
:set ic
/spider[- ]\=man
Example 1-37. Simple substitution in vi
Globally convert <br> to <br /> for XHTML compliance.
:set ic
: % s/<br>/<br \/>/g
Example 1-38. Simple substitution in Vim
Globally convert <br> to <br /> for XHTML compliance.
: % s/<br>/<br \/>/ig
Example 1-39. Harder substitution in Vim
Urlify: Turn URLs into HTML links
: % s/\(https\=:\/\/[a-z_.\\w\/\\#~:?+=&;%@!-]*\)/< a href="
\1">\1<\/a>/ic
Get Regular Expression Pocket Reference, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.