Source Insight provides a "C-like" macro language which is useful for scripting commands, inserting specially formatted text, and automating editing operations.
Here is the basic idea. You write macros in a file with a .EM extension and add them to your project, or to any project on the Project Symbol Path (General Options dialog), or to the Base project. Once you do that, the macros become available as commands in the Key Assignments or Menu Assignments dialogs.