Friday, April 29, 2011

Re: capture result of a global search

On 04/29/2011 03:59 PM, cyboman wrote:
> does anybody know if there is a way to capture the result of a global
> search in vim.
>
> for example in perl i can do the following
> string =~ /(pattern1)someword/i
> and $1 will contain patter1.
>
> is something like this possible in vim scripting?

You don't mention explicitly where you want it. You can use

:redir

to capture to various locations (variables, files, registers).
You can read more at

:help :redir

Alternatively, you can append the resulting matches:

:let s ='' |g/pattern/let s += getline('.')

-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

No comments: