Friday, June 25, 2010

Re: 1) Serach in the current file for all the match of regular expression X. 2) Insert at the cursor's current position the matches just founded.

Hi Robbo!

On Fr, 25 Jun 2010, Robbo wrote:

> Hi,
> I need to write a command that acts as following:
>
> 1) Serach in the current file for all the match of regular expression
> X.
> 2) Insert at the cursor's current position the matches just founded.
>
> Could you give me some hints?

Try something like this:
let @a=''|let cp=winsaveview()|g/RE/exe "norm! //\n\"Ay//e\n"|let @A="\n"|call winrestview(cp)
(one line)

Instead of RE use your Regular expresion, you'd like.
You should now have each match separated by newlines in register a. Use
:put a
to place it after the current cursor position.

regards,
Christian

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

Post a Comment