Friday, April 11, 2008

Coding Productivity Macro

Kirill Osenkov : Coding productivity: macros, shortcuts and snippets

This macro by Kirill Osenkov inserts a pair of curly braces and places the cursor inside them. It's useful when mapped to Shift+Enter.


Sub InsertCurlies()
    DTE.ActiveDocument.Selection.NewLine()
    DTE.ActiveDocument.Selection.Text =
"{"
    DTE.ActiveDocument.Selection.NewLine()
    DTE.ActiveDocument.Selection.Text =
"}"
    DTE.ActiveDocument.Selection.LineUp()
    DTE.ActiveDocument.Selection.NewLine()
End Sub