tags:

views:

14

answers:

1

Hello, Is it possible to use toupper in replacement string? Suppose, there are member Declarations like this:

int myVar;

I want to make the first letter of variable name to a capital-letter:

int MyVar;

Unfortunately this doesn't work:

:1,$s/\(\w\+\)\s\+\(\w\)\(\w*\)\s*;/\1 \=toupper(submatch(\2))\3;/

Finally, I could use \u for doing this:

:1,$s/\(\w\+\)\s\+\(\w\)\(\w*\)\s*;/\1 \u\2\3;/

But I am still curious if using functions like toupper within the replacement string works?

+1  A: 

Try:

:1,$s/\(\w\+\)\s\+\(\w\)\(\w*\)\s*;/\=submatch(1)." ".toupper(submatch(2)).submatch(3).";"/
Jeet
Great, it works! Thank you very much! I see, the strings should be enclosed in "" and concatenated with other strings or function results using dot. Thank you very much!
Valentin Heinitz