Vim how to search url

How would you look for the next line in vim?

http://my.url.com/a/b/c 

I tried (a la Very No Magic)

 :/\Vhttp://my.url.com/a/b/c 

But it gives me:

E492 not an editor command: /\Vhttp://my.url.com/a/b/c

You would think that there would be an easy way to search for a string literally ... I am not too interested in slashing every slash or writing a complex search, because I have to quickly look for different URLs in the text file.

+6
source share
5 answers

I am not sure why you get not an editor command , since I do not. The easiest way to search without dropping is to use instead ? , eg.

 :?http://my.url.com/a/b/c " or since the : is not necessary ?http://my.url.com/a/b/c 

This is a search in a different direction, so just keep that in mind.

+8
source

Another way to look forward (from the position of your cursor) without escaping is to use the command :s .

You can do:

 :% s@http ://my.url.com/a/b/ c@ @n 

then press n to move inverted text forward, n backward

If you want to know how many matches are in the buffer, use gn instead of n

Notice that I said "without running away", I was talking about the oblique line, if you want to accurately perform the search, you need to avoid the period. . . since in regex . means any char.

+3
source

You can also directly set the search register.

 :let @/='\Vhttp://my.url.com/a/b/c' 

Then you can use n and n as usual.

0
source

Use MacVim (or GVim). Open a GUI search without a regex using ⌘ f (or ctrl f on Windows). This is the recommended way to search without regular expressions in Vim. The Vim GUI has many improvements over a vim terminal, like this one, and I would strongly suggest using it full time if you haven’t already.

0
source

Searching in vim is just / , not :/ . You can search for this line, which supplants only slashes: /http:\/\/my.url.com\/a\/b\/c

-1
source

Source: https://habr.com/ru/post/945022/


All Articles