It depends on what you mean by a buffer.  The basic idea of using
:g should work, and there are a lot of different ways to use it.  For
example,

:let @a = ""
:g/\<c\a*/let @a .= matchstr(getline("."), @/) . "\n"

will copy all words starting with "c" into the a register.  You cna then
do

:new
:put a

if you want to put the text into a buffer.  (Or use "ap in Normal mode.)
Problem:  this only grabs the first pattern that appears on a line.
Solution:  use the Pippo() function from foo.vim, my file of sample vim
functions:

http://www.vim.org/script.php?script_id=72

HTH                                     --Benji Fisher

On Wed, May 31, 2006 at 04:06:20PM +0530, SHANKAR R-R66203 wrote:
> This will copy the entire line.
> I do not want to copy the entire line, but just the pattern.
> 
> >-----Original Message-----
> >From: Vishnu [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, May 31, 2006 3:53 PM
> >
> >Hi Shankar,
> >
> >
> >:g/<pattern>/t$
> >
> >t - copy to address $
> >
> >
> >you can call function instead of t$
> >
> >-----Original Message-----
> >From: SHANKAR R-R66203 [mailto:[EMAIL PROTECTED]
> >Sent: Wednesday, May 31, 2006 3:41 PM
> >
> >Hi Vimmers,
> >
> >   I want to copy everything that matches a search pattern.
> >
> >For example, if my search pattern is
> >
> >/\$.*s
> >
> >I want to copy all the patterns that matches this into a buffer.
> >
> >How can I do this ?

Reply via email to