25

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.

Matthew Strawbridge
  • 19,940
  • 10
  • 72
  • 93
user5628973
  • 311
  • 1
  • 3
  • 5

1 Answers1

32

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.

Xavier T.
  • 40,509
  • 10
  • 68
  • 97