Use of the Macro

Our new example adds prefix and suffix text to a series of selected lines. This macro can be used to reduce typing for a series of text items that must be preceded and following by identical text. In Java, for example, if we are interested in making a series of calls to StringBuffer.append() to construct a lengthy, formatted string, we could type the parameter for each call on successive lines as follows:

profileString_1
secretThing.toString()
name
address
addressSupp
city
“state/province”
country

Our macro would ask for input for the common “prefix” and “suffix” to be applied to each line; in this case, the prefix is ourStringBuffer.append( and the suffix is );. After selecting these lines and running the macro, the resulting text would look like this:

ourStringBuffer.append(profileString_1);
ourStringBuffer.append(secretThing.toString());
ourStringBuffer.append(name);
ourStringBuffer.append(address);
ourStringBuffer.append(addressSupp);
ourStringBuffer.append(city);
ourStringBuffer.append(“state/province”);
ourStringBuffer.append(country);