"<word1 word2 ... wordn>"

lower case words with spaces between them enclosed in
angle brackets. (the ... means 0 or more).
I would like a macro (place cursor within <>s and execute
macro) that converts the
above to:       

    "Word1Word2...Wordn"

Is the only way to do this to write a function?


Nope. I'm sure there are plenty of ways. :)

Here's the "tim" way...

Assuming that you want to do all of them in a file, you can use

%s/<\(\_[^>]*\)>/\=substitute(submatch(1), '\(\<\w\+\)\s*', '\u\1', 'g')

A bit hairy, but does what you describe.

May be modifiable to be mapped to only apply to the one in which the cursor resides...something like this untested

%s/<\(\_[^>]*\%#\_[^>]*\)>/\=substitute(submatch(1), '\(\<\w\+\)\s*', '\u\1', 'g')/g

If it's a problem to follow along, let me know and I can help break it down and try to make it less opaque.

-tim




Reply via email to