The code is more difficult, it will inevitably have a lot of repetitive work, such as each member function and parameter write instruction document, etc., for this purpose, macro can improve efficiency. Below is the macro I wrote and some improved, you can add to VS2003 Inside the macro manager, you can use it.
Option Strict Off
Option expendit off
Imports envdte
Imports system.diagnostics
Imports system.windows
Imports System.Windows.Forms
Imports system
Imports system.collections.specialized
Public Module Ownmacros
'Paste text in front of the text selected
Public Sub Pasteatbegin ()
Pastetext (0)
End Sub
'The last paste of the selected text
Public Sub Pasteatend ()
Pastetext (1)
End Sub
'Paste the text before and after the selected text
Public Sub Pasteatbenginend ()
Pastetext (2)
End Sub
'Paste text
Private sub pastetext (byval position as integer)
DIM BEGINLINE, ENDLINE AS INTEGER
DIM ObjtextSelection As TextSerection
DIM I as integer
ObjtextSelection = ctype (DTE.ActiveDocument.selection (), envdte.textselection
Beginline = ObjtextSelection.Anchorpoint.Line
Endline = objtextSelection.bottompOint.Line
For i = beginline to endline
ObjtextSelection.gotoline (i, false)
IF position = 0 or position = 2 THEN
ObjtextSelection.Startofline (vSstartoflineOptions.vsstartoflineOptionsfirsttext)
ObjtextSelection.Paste ()
END IF
If position = 1 or position = 2 THEN
ObjtextSelection.endofline ()
ObjtextSelection.Paste ()
END IF
NEXT
End Sub
'Paste multiple lines of text
Sub multilinepaste ()
DIM BEGINROW, ENDROW AS INTEGER
DIM ObjtextSelection As TextSerection
DIM I as integer
DIM Value As New StringCollection
ObjtextSelection = CType (DTE.ActiveDocument.selection, Envdte.TextSerection)
BeginRow = objtextSerection.Anchorpoint.Line
Endrow = objtextSelection.bottompoint.Line
IF BeginRow For i = beginrow to endrow ObjtextSelection.gotoline (i, false) ObjtextSelection.Startofline (vSstartoflineOptions.vsstartoflineOptionsfirsttext) ObjtextSelection.endofline (true) value.add (objtextSelection.text) ObjtextSelection.delete () NEXT ObjtextSelection.gotoline (BeginRow, False) ObjtextSelection.Paste () For i = beginrow to endrow ObjtextSelection.gotoline (i, false) ObjtextSelection.Startofline (vSstartoflineOptions.vsstartoflineOptionsfirsttext) ObjtextSelection.Insert (Value.Item (i - beginRow)) ObjtextSelection.insert ("") NEXT Value.clear () END IF End Sub SUB MULTILINEREPERT () DIM BEGINROW, ENDROW AS INTEGER DIM ObjtextSelection As TextSerection DIM I as integer ObjtextSelection = CType (DTE.ActiveDocument.selection, Envdte.TextSerection) BeginRow = objtextSerection.Anchorpoint.Line Endrow = objtextSelection.bottompoint.Line IF BeginRow For i = beginrow to endrow ObjtextSelection.gotoline (i, false) ObjtextSelection.Startofline (vSstartoflineOptions.vsstartoflineOptionsfirsttext) ObjtextSelection.endofline (TRUE) ObjtextSelection.copy () ObjtextSelection.endofline (false) ObjtextSelection.Insert (Microsoft.visualBasic.Constants.vbtab Microsoft.VisualBasic.Constants.vbtab) ObjtextSelection.Paste () NEXT END IF End Sub 'Adding VB comments for selecting text Public Sub Addvbcomment () AddcommentInfo (0) End Sub 'Add a VC annotation for the selected text Public Sub AddVCComment () AddcommentInfo (1) End Sub 'Add an comment text Private sub addcommentinfo (Byval Type as integer) DIM ObjtextSelection As TextSerection DIM Comment As String Dim text as string ObjtextSelection = CType (DTE.ActiveDocument.selection, Envdte.TextSerection) Text = ObjtextSelection.Text If Type = 0 THEN Comment = "'" END IF If Type = 1 THEN Comment = "//" END IF ObjtextSelection.Lineup () ObjtextSelection.Newline () objtextSelection.text = Comment " ObjtextSelection.newline () ObjtextSerection.Text = Comment Text ObjtextSelection.newline () ObjtextSelection.Text = Comment " summary>" End Sub Public Sub Clearscript () DIM BeginPoint As VirtualPoint DIM Endpoint As VirtualPoint DIM ObjtextSelection As TextSerection DIM B, E AS INTEGER Dim Bline, Eline As Integer DIM FINDRESULT As Boolean ObjtextSelection = CType (DTE.ActiveDocument.selection, Envdte.TextSerection) 'objtextSelection.Startofdocument (false) FindResult = TRUE While FindResult = TRUE FindResult = FALSE