Since you are marking C ++, you must add classes with the built-in wizard. The wizard creates the #pragma once directives. It is even available for other compilers: # pragma once so that you do not break plattform cross-compatibility.
However, you can create a VS macro like this:
Option Strict Off Option Explicit Off Imports System Public Module HeaderGuard Sub InsertHeaderGuard() Dim filename As String = DTE.ActiveDocument.Name filename = filename.ToUpper().Replace("."c, "_"c) DTE.ActiveDocument.Selection.Text = "#ifndef " + filename DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.Text = "#define " + filename DTE.ActiveDocument.Selection.NewLine(2) DTE.ActiveDocument.Selection.Text = "#endif /* " + filename + " */" DTE.ActiveDocument.Selection.NewLine() End Sub End Module
source share