user2485710
user2485710

Reputation: 9801

quickly manipulate and add duplicates of a word in Vim line by line

I have a really simple task but I can't find a way to do it; I have a text file that is composed like so

$CC
$CXX

where each line is the name of an environment variable and I would like to morph the previous into

echo "CC"$CC
echo "CXX"$CXX

and of course adding text in before and after each word on each line it's easy, especially in visual mode, but I can't really find a way to say to vim "copy the word after the dollar sign and paste it at some point in the sequence that I input in visual mode"

Someone got some ideas ?

Upvotes: 0

Views: 63

Answers (1)

Kent
Kent

Reputation: 195169

does this help?

:%s/\v\$(\S*)/echo "\1"&/

Upvotes: 2

Related Questions