As a Scite (Scintilla) Text Editor user, I use the keyboard shortcut of line switching ("CTRL + T") frequently. It's helpful for me in the web app development environment. Come to dot net development months ago, I am surpised that Visual Studio lack of this feature. Luckily, I am able to write macro for this custom function.
Sub SwitchLine()
Dim thisLine As String
Dim lastLine As String
' get current line, set cursor to start of line
DTE.ActiveDocument.Selection.StartOfLine(0)
' set cursor to end of line
DTE.ActiveDocument.Selection.EndOfLine(True)
' copy the selection into thisLine
thisLine = DTE.ActiveDocument.Selection.Text
' set cursor to end of line
DTE.ActiveDocument.Selection.EndOfLine()
'set cursor to last line
DTE.ActiveDocument.Selection.lineUp()
'set cursor to start of line of this lastline
DTE.ActiveDocument.Selection.StartOfLine(0)
' set cursor to end of line
DTE.ActiveDocument.Selection.EndOfLine(True)
' copy the selection into thisLine
lastLine = DTE.ActiveDocument.Selection.Text
' set cursor to end of line
DTE.ActiveDocument.Selection.EndOfLine()
' copy this line text to last line
DTE.ActiveDocument.Selection.StartOfLine(0)
DTE.ActiveDocument.Selection.EndOfLine(True)
DTE.ActiveDocument.Selection.Text = thisLine
DTE.ActiveDocument.Selection.EndOfLine()
'copy last line text to this line
DTE.ActiveDocument.Selection.lineDown()
DTE.ActiveDocument.Selection.StartOfLine(0)
DTE.ActiveDocument.Selection.EndOfLine(True)
DTE.ActiveDocument.Selection.Text = lastLine
DTE.ActiveDocument.Selection.EndOfLine()
End Sub
|
Top
|




Top
Loading...
Rss Feed
