Wiki

by yszheda

View project onGitHub

Tip 74: Use the V Literal Switch for Verbatim Search

Return to the top: <<Practical Vim>>

Use of \V means that in the pattern after it, only the backslash has a special meaning.

References:

# If you open the file in vim,
# then you can \"ayy@a the next line to execute the vim command: 
:h /\V

Example: Search 'a.k.a'

  • running /a.k.a: "." symbol matches any character
  • escaping: /a\.k\.a\.
  • using \V literal switch to enable very nomagic search: /\Va.k.a.

History Lesson: On the Heritage of Vim's Pattern Syntax

Vim's default is magic search, while nomagic search emulates the behavior of vi. They can enabled with the \m and \M switches, respectively.

  • \M is similar to \V, except that '^' and '$' symbols automatically take on a special meaning.