Vim Recall繁體中文

Treat punctuation as literal text

:%s/\Va.b/X/g

Example

Normal mode. Line: a.b a-b a.b.

Before
a.b a-b a.b
  1. :%s/\Va.b/X/g<CR> X a-b X · only literal a.b matches
After
X a-b X
Details & 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

  1. Run :%s/\Va.b/X/g<CR>.
  2. \V makes the dot literal in the pattern.
  3. Use an alternative delimiter when it makes paths easier to read.