I have lines like the following ones (actually function prototypes)
void ()
word ( word, another word, one_more word, ..., hello, ... )
one argument ( only )
I want to match each single argument and enclose it between < and >.
Before wasting time with the replacement string, I'm trying to devise the proper search pattern. The following command
:%s/\(( \|, \)\(.\{-}\)\( )\|,\)/\1<\2>\3/g
only matches and replace odd-position arguments.
%s/ \(\w[^,)]\+\)/<\1>/g. This is good too, but it fails when something (not necessarly a comment) follows the closing parenthesis. What do you think about it? – Enlico Sep 18 '16 at 22:12%s/(\zs\(.*\)\ze)/\=substitute(submatch(1), '\(\w[^,)]\+\)', '<\1>', 'g')– dNitro Sep 18 '16 at 23:52