How to search a string with spaces and special characters in vi editor

46,334

Numbers and spaces are not special characters so

 /Dec 1 15 

is enough.

Generally speaking special characters are escaped with a \. For example, if you search for Dec., you should type /Dec\.

If you are using Vim, you might also want to check

:help pattern.txt

And specifically the magic chapter.

If you want to know if magic is set, type :set magic?

The magic option can change the behavior of pattern matching.

Share:
46,334
user5628973
Author by

user5628973

Updated on March 11, 2020

Comments

  • user5628973
    user5628973 about 4 years

    I edit in the vi editor. I want to search in the text for a specific phrase, e.g "Dec 1 15:13:00". I have tried this search string, but it's not working:

    /Dec\ 1\ 15
    

    How do I search for this string properly? Note that there may be more than one space between the parts.