On 10/3/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

Can you help me please?
I have a long text and I need to find all words beginning with "hell" and
copy these words at the end of the file.
I found a helpful command :g/hell/t$
But this command copies the whole line. I want only the relevant word (and
each word on a new line).

Does the following do what you want, when you press F5:

function! CopyHellWords()
  exe "norm Gmao\<esc>gg"
  let kount=0
  while line('.') <= line("'a")
     if expand('<cword>') =~ "^hell"
         call append(line('$'), expand('<cword>'))
         let kount = kount + 1
     endif
     call search('\<')
  endw
  echo kount . "words copied"
endfun

nmap <F5> :call CopyHellWords()<cr>

Yakov

Reply via email to