Victor S
Victor S

Reputation: 4191

How to search </string> in vim?

I want to search in vim,

/</string>

but it didn't work, how to do can exactly match "</string>"?

Upvotes: 6

Views: 17172

Answers (5)

Michael_Maier
Michael_Maier

Reputation: 59

Use :s instead. Eg.

%:s:/home/johndoe/.git::gc

This examples searches for the pathname (g for greedy) and replaces with nothing, if the user confirms (c for confirm) help :s (help on substitute) does not tell that one may use any character to separate search and replace strings. It doesn't have to be a slash /

Upvotes: 0

Netwidz
Netwidz

Reputation: 179

Try to search by escaping the/ by adding \ before the /.

Eg: /<\/string>

This will work

Upvotes: 4

user1784602
user1784602

Reputation:

If you're trying to search for a literal value, the \V "very no magic" prefix can be helpful. When specified, every character except \ is treated as its literal value, so in your case /\V would match exactly what you want. I often find it more readable than interspersing backslashes through the pattern.

You can look at :help magic for more information.

Upvotes: 6

Ingo Karkat
Ingo Karkat

Reputation: 172510

An alternative to escaping the slash (\/) is to use the backward-search: ?</string> (and navigating to next matches with N instead of n).

Upvotes: 15

Roland Jansen
Roland Jansen

Reputation: 2783

Escape the "/" with a backslash:

/<\/string>

Upvotes: 13

Related Questions