Friday, April 9, 2010

Re: Is there a variable containing all tokens that matched a regex search term?

On 9 April 2010 22:25, tomPorter wrote:

> If I enter a regex search term, all occurrences of the
> matched items in a window will be highlighted.
>
> Is there a way to create a new window and populate it
> with only the found items?
>
> OR is there a variable that contains all items matching
> the regex search term?
>
> Example:
>
> A colleague is working on a some large files where we use
> substitution variables than start with '&&'. Assume
> these are terminated by white space, so are 'words' to
> vim.
>
> [...]

For a quick a quick hack, try this.

:let tokens=[]
:%s/&&\S\+/\=add(tokens,submatch(0))/g
:undo
:new
:put=tokens

--Antony

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

To unsubscribe, reply using "remove me" as the subject.

No comments: