"BPJ" <[email protected]>:
> Is there any way when using :g to copy the matched substring only?
> 
> I want to find all lines with CamelCase words and copy those
> words to the bottom of the buffer.
> 
>      :g/\a*\l\U\a*/t$
> 
> copies the whole line, but I want to get the part of the line
> matching the pattern.

Quick solution:

    g/\a*\(\l\u\|\u\l\)\a*/call setline(line('$')+1, matchstr(getline('.'), 
'\a*\(\l\u\|\u\l\)\a*'))

Notes:
- I've replaced \U with \u, since \U means [^A-Z].
- I've replaced \l\u with \(\l\u\|\u\l\), otherwise words starting with an
uppercase letter won't be found.

Best,
Paul

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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to