VS Macro won't run to EOF - RegEx Find / Replace to the rescue
I needed to generate insert scripts using values from an Excel file - one per row, hundreds of rows. I exported to CSV, opened in VS.NET, and got ready to run a macro to pop some SQL before and after each line in the CSV. I recorded my macro and went looking for the “Run to end of file” menu item... not there! The only ways to repeat a macro for each line in a file is to hit CTRL-SHIFT-P hundreds of times or to edit the Macro manually and make it loop (which for some reason runs more slowly than typing each letter in with one finger).
That was a surprise - UltraEdit has “play until end of file”, and I seem to remember a lot of other editors having it, too.
I was debating whipping up a snippet in SnippetCompiler or manually running my macro hundreds of times, when I remembered how Regex Find / Replace had helped before. Sure enough...
Find: ^
Replace: INSERT INTO table (column, column, column) SELECT value, '
and
Find: $
Replace: ', value;
The ^ matches the beginning of every line; the $ matches the end of every line. An added bonus is that the RegEx find / replace is lightning quick.