So basically I copy/pasted some code, and I need to prepend and append some more code to each line. Each line is a function call, and is getting added to a switch statement as it's own case.
Right now it looks like:
switch(n)
{
case 1: retVal = foo("bar"); break;
case 2: retVal = foo("Bar"); break;
foo("bAr");
foo("BAr");
foo("BAR");
}
And I need it to look like:
switch(n)
{
case 1: retVal = foo("bar"); break;
case 2: retVal = foo("Bar"); break;
case 3: retVal = foo("bAr"); break;
case 4: retVal = foo("BAr"); break;
case 5: retVal = foo("BAR"); break;
}
The best I've come up with is:
:'<,'>s/I DONT KNOW/case SOMETHING: retVal = & break;/g
where I DON'T KNOW
and SOMETHING
need to be changed. The problem is I'm not comfortable enough with regex to know what to put there. Any ideas?
Edit: After seeing muru's answer I realized I should've posted this link for the numbering part. Example 11 shows a way to renumber a sequence using regex, assuming you have an existing sequence.