How can I include the period (.) in Vim's search and replace command? (replacing .html extensions)?
28,437
Solution 1
Escape it. The .
is a regex character which means "any character", so you need to escape it with \
.
:%s/\.html/.php/g
Solution 2
Just escape the .
character.
Search for /\.html
Solution 3
Try escaping period character: /\.html
Solution 4
Use backslach to escape the dot.
/\.html
will look for ".html".
Comments
-
alexchenco over 3 years
When I do:
/.html
Vim looks forhtml
I would like to replace all the
.html
with.php
Something like this:
:%s/html ext/php ext/g
-
Tim Visée almost 6 yearsNote that the
.
is for any character except a new line.