Generally, code files must have a document header with copyright instructions and help information. I used ctrlc and ctrlv in the past. Later I studied the online materials and found it convenient to use macros to complete this task.
Choose macro> macro IDE from the tool menu, add a new item in the macro editor, and select a module. Well, the module name is "addmediaentheader.
Edit the Code as follows:
Imports system
Imports envdte
Imports envdte80
Imports envdte90
Imports envdte90a
Imports envdte100
Imports system. Diagnostics
Public module addmediaentheader
Sub addmediaentheader ()
Dim document as document
Document = DTE. activedocument
Document. selection. startofdocument ()
Document. selection. gotoline (2, true)
Dim content as string = Document. selection. Text
'Compare the copyright information string of the second line of the Code to determine whether to add a file header.
Dim copyrightinformation as string = "Copyright (c) xwingyz (AT) gmail.com. All right reserved ."
Dim MS = "*" + copyrightinformation
Dim found = string. Compare (content, MS)
If (found <> 0) then
Document. selection. startofdocument ()
Document. selection. Lineup ()
Document. selection. Text = "/*-----------------------------------------------------------------------------"
Document. selection. newline ()
Document. selection. Text = copyrightinformation
Document. selection. newline ()
Document. selection. newline ()
Document. selection. newline ()
Document. selection. Text = "$ lastchangedby $"
Document. selection. newline ()
Document. selection. Text = "$ lastchangeddate $"
Document. selection. newline ()
Document. selection. Text = "$ lastchangedrevision $"
Document. selection. newline ()
Document. selection. Text = "-----------------------------------------------------------------------------"
Document. selection. newline ()
Document. selection. Text = "/"
Document. selection. newline ()
End if
End sub
End Module
Save and exit.
Open a code file, select macro> macro Resource Manager from the tool menu, right-click the created module addmediaentheader, and choose run from the shortcut menu to see if the file header is automatically added to the Code? Run the following command again to check if there is no repeated addition? Everything is okay without an accident.
The next step is to assign a shortcut key to this macro, which makes it easier.
Find the options in the tool menu-> keyboard options, enter addmediaentheader in the filter box, and you will see the macro you just created? Allocate a shortcut that you like.