Friday, December 14, 2018

Re: search file for text in reg ?

On 2018-12-14 09:48, M Kelly wrote:
> Is there a way to search a file for the text that is in a register ?

Is the content of the register literal text or a regular expression?

If it's a regular expression (or doesn't have any regex metachars in
it), you can use

:let @/=@a

where "@a" is the register in question. You can then use n/N to
navigate forward/backward.

If it's literal text that might contain regexp metachars, you have to
escape them:

:let @/=escape(@a, '.*\\$^')

(adjust the set of escaped characters accordingly; I just grabbed a
few I knew to be problematic)

-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: