Friday, April 9, 2010

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

On Fri, Apr 9, 2010 at 16:25, tomPorter <tom.x.porter@gmail.com> wrote:
OR is there a variable that contains all items matching the regex
search term

I found this function (CopyMatches) online a while ago from here: http://vim.wikia.com/wiki/Copy_the_search_results_into_clipboard.  Just follow the instructions and you should be good to go.  Don't forget to clear the register first!  (q {register letter} q);  So if you're going to copy them into register 'a' this is what I do (*<CR> denotes press enter):

/&&\w*<CR>
qaq
:%CopyMatches a<CR>
{Navigate to wherever you want the text}
"ap


Since I use this a lot I have this shortcut defined in my vimrc:
:noremap ,a  qaq:%CopyMatches a<CR>

So once I have my search down I just go ',a' and then everything is in buffer a :D

~Adam~

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