Wednesday, January 15, 2014

Re: Copy the matched substring only with :g

2014-01-15 20:50, Tim Chase skrev:
> On 2014-01-15 15:29, Paul Isambert wrote:
>> g/\a*\(\l\u\|\u\l\)\a*/call setline(line('$')+1,
>> matchstr(getline('.'), '\a*\(\l\u\|\u\l\)\a*'))
>
>
> Riffing off Paul's solution, I'd suggest
>
> :g/\<\w*\l\u\w*\>/call setline(line('$')+1, matchstr(getline('.'), @/))
>
> which removes the need to specify the pattern twice, using the "/"
> register to specify it to matchstr.

Nice! I'll try to remember that.

>
> The regexp can be tweaked (I chose the above as my "there's something
> camelCase" regexp), but there are cases you'd have to make a
> determination on camelCase'ness:
>
> HTMLobject
> MyObject
> _myProperty
> _MyObject
> InnerHTML
> THIS_IS_HTML
>

Yes, and it turned out some of my cC words were really plain old
Titlecase, hence the second branch in the pattern of my perl
filter solution.

/bpj

--
--
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 vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment