On 2015-02-11 13:24, Brian L. Matthews wrote:
> This is probably one of those "You use vim and don't know how to do
> that?!?!" things, but I'd like to be able use the contents of a
> register in a search. I often have some text and want to find out
> where else that text occurs. I can get the text into a register,
> but then would like to search for that text.
You're close. You can use control+R followed by the register-name to
insert that register at the search prompt. So you can do something
like
/<C-R>b
to insert the content of the "b" register at the search prompt. Note
that this is interpreted as a regular expression, so if your register
contains regex metacharacters, you'd have to escape them. Which can
be done from a mapping with something like
:cnoremap <f4> <C-R>=escape(@b, '.\*/')<cr>
where the ".\*/" is a list of characters to escape.
You can read up more at
:help c_CTRL-R
:help @=
:help escape()
if you want the ugly details.
-tim
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment