How would you search for the following string in vim?
http://my.url.com/a/b/c
I've 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 there'd be a simple way to search a string literally... I'm not too interested in slash escaping every slash, or writing a complicated search, because I have to rapidly search different URLs in a text file.
If you have Vim and Netrw, you can open a URL in your browser of choice, right from the editor. Place the cursor on the URL and type gx . This will invoke your file handler; open for OSX.
To find a character string, type / followed by the string you want to search for, and then press Return. vi positions the cursor at the next occurrence of the string. For example, to find the string “meta,” type /meta followed by Return. Type n to go to the next occurrence of the string.
To search using Vim/vi, for the current word: In normal mode, you can search forward or backward. One can search forward in vim/vi by pressing / and then typing your search pattern/word. To search backward in vi/vim by pressing ? and then typing your search pattern/word.
I'm not sure why you get not an editor command
since I don't. The simplest way to search without having to escape slashes is to use ?
instead, e.g.
:?http://my.url.com/a/b/c
" or since the : is not necessary
?http://my.url.com/a/b/c
This does search in the other direction, so just keep that in mind
another way to search forward (from the position of your cursor) without escaping is use :s
command.
you could do:
:%s@http://my.url.com/a/b/c@@n
then press n
to navigate matched text forward, N
backwards
If you want to know how many matches in the buffer, use gn
instead of n
note that, I said "without escaping", I was talking about the slash, if you want to do search precisely, you have to escape the period. .
. since in regex, .
means any char.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With