Treat punctuation as literal text
:%s/\Va.b/X/g
Example
Normal mode. Line: a.b a-b a.b.
a.b a-b a.b- :%s/\Va.b/X/g<CR> X a-b X · only literal a.b matches
X a-b XDetails & Vim help
Use \V so most punctuation in a search pattern loses its special meaning.
Replace dotted names without accidentally matching other characters.
Even with \V, backslash and the command’s delimiter still need care. This affects the pattern only; replacement characters such as & and backslash retain their meaning.
Try it in Vim
- Run :%s/\Va.b/X/g<CR>.
- \V makes the dot literal in the pattern.
- Use an alternative delimiter when it makes paths easier to read.