MetallicPriest
MetallicPriest

Reputation: 30841

How do I search words separated by spaces in Vim

So I can search a word in Vim using /. However, it only searches for one word. For example, if I search "Stack Overflow", it only searches for "Stack". How can I ask Vim to search the whole "Stack Overflow"?

Upvotes: 5

Views: 10442

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172788

Though you need to escape certain characters to prevent them from being interpreted as regular expression atoms (which can be reduced by prepending the \V "very nomagic" atom; then, only backslashes need to be escaped), whitespace does not need escaping. Therefore, it should be possible to search (starting from normal mode) simply via /Stack Overflow, and concluding with Enter.

If that doesn't work for you, a plugin or custom configuration has corrupted your Vim.

Upvotes: 13

Santosh A
Santosh A

Reputation: 5361

Use backslash \ before space in search string.

To search for "Stack Overflow" use "Stack\ Overflow" in command mode.

Upvotes: 8

Related Questions