Skip to main content
Correct typo
Source Link

I have to replace a lot of variables s1.size() with wa, and replace s2.size() with wb accordingly. I have made next substitution request:

:'<,'>s/\vs([1|2])\.size\(\)/w\={"1":"a","2":"b"}[submatch(1)]/g

But it wont work. Also, if I remove that w from replacement field,

:'<,'>s/\vs([1|2])\.size\(\)/\={"1":"a","2":"b"}[submatch(1)]/g

it does almost what I want but of course it will replace just s1.size() with a and s2.size() with b without w.

HotHow to put the vim script evaluation command \= and some text together in replacement field of substitute command?

I could not find help about \= with :help, if you know, please provide me a correct prompt to get vim help about \= command.

I have to replace a lot of variables s1.size() with wa, and replace s2.size() with wb accordingly. I have made next substitution request:

:'<,'>s/\vs([1|2])\.size\(\)/w\={"1":"a","2":"b"}[submatch(1)]/g

But it wont work. Also, if I remove that w from replacement field,

:'<,'>s/\vs([1|2])\.size\(\)/\={"1":"a","2":"b"}[submatch(1)]/g

it does almost what I want but of course it will replace just s1.size() with a and s2.size() with b without w.

Hot to put the vim script evaluation command \= and some text together in replacement field of substitute command?

I could not find help about \= with :help, if you know, please provide me a correct prompt to get vim help about \= command.

I have to replace a lot of variables s1.size() with wa, and replace s2.size() with wb accordingly. I have made next substitution request:

:'<,'>s/\vs([1|2])\.size\(\)/w\={"1":"a","2":"b"}[submatch(1)]/g

But it wont work. Also, if I remove that w from replacement field,

:'<,'>s/\vs([1|2])\.size\(\)/\={"1":"a","2":"b"}[submatch(1)]/g

it does almost what I want but of course it will replace just s1.size() with a and s2.size() with b without w.

How to put the vim script evaluation command \= and some text together in replacement field of substitute command?

I could not find help about \= with :help, if you know, please provide me a correct prompt to get vim help about \= command.

Source Link

How to evaluate vim script in the substitution field and put text with it?

I have to replace a lot of variables s1.size() with wa, and replace s2.size() with wb accordingly. I have made next substitution request:

:'<,'>s/\vs([1|2])\.size\(\)/w\={"1":"a","2":"b"}[submatch(1)]/g

But it wont work. Also, if I remove that w from replacement field,

:'<,'>s/\vs([1|2])\.size\(\)/\={"1":"a","2":"b"}[submatch(1)]/g

it does almost what I want but of course it will replace just s1.size() with a and s2.size() with b without w.

Hot to put the vim script evaluation command \= and some text together in replacement field of substitute command?

I could not find help about \= with :help, if you know, please provide me a correct prompt to get vim help about \= command.