Hi , after a lot of search , I really want to fix this.. "Is there a Short Cut Key for Duplicate Line exists in Visual Studio 2008 "?
Duplicate Line i.e. like Ctrl+j in Edit Plus or Crtl+D in Notepad++
Hi , after a lot of search , I really want to fix this.. "Is there a Short Cut Key for Duplicate Line exists in Visual Studio 2008 "?
Duplicate Line i.e. like Ctrl+j in Edit Plus or Crtl+D in Notepad++
Look at this link, you need to create macro to create the shortcut... Duplicate line command for Visual Studio
If you like eclipse style line (or block) duplicating using CTRL+ATL+UP or CTRL+UP+DOWN, below I post macros for this purpose:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Public Module DuplicateLineModule
Sub DuplicateLineDown()
Dim selection As TextSelection = DTE.ActiveDocument.Selection
Dim lineNumber As Integer
Dim line As String
If selection.IsEmpty Then
selection.StartOfLine(0)
selection.EndOfLine(True)
Else
Dim top As Integer = selection.TopLine
Dim bottom As Integer = selection.BottomLine
selection.MoveToDisplayColumn(top, 0)
selection.StartOfLine(0)
selection.MoveToDisplayColumn(bottom, 0, True)
selection.EndOfLine(True)
End If
lineNumber = selection.TopLine
line = selection.Text
selection.MoveToDisplayColumn(selection.BottomLine, 0)
selection.EndOfLine()
selection.Insert(vbNewLine & line)
End Sub
Sub DuplicateLineUp()
Dim selection As TextSelection = DTE.ActiveDocument.Selection
Dim lineNumber As Integer
Dim line As String
If selection.IsEmpty Then
selection.StartOfLine(0)
selection.EndOfLine(True)
Else
Dim top As Integer = selection.TopLine
Dim bottom As Integer = selection.BottomLine
selection.MoveToDisplayColumn(top, 0)
selection.StartOfLine(0)
selection.MoveToDisplayColumn(bottom, 0, True)
selection.EndOfLine(True)
End If
lineNumber = selection.BottomLine
line = selection.Text
selection.MoveToDisplayColumn(selection.BottomLine, 0)
selection.Insert(vbNewLine & line)
selection.MoveToDisplayColumn(lineNumber, 0)
End Sub
End Module
Not an answer, just a useful addition: As a freebie, I just invented (well... ehm... adjusted the code posted by Lolo) a RemoveLineOrBlock macro. Enjoy!
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Public Module RemoveLineOrBlock
Sub RemoveLineOrBlock()
Dim selection As TextSelection = DTE.ActiveDocument.Selection
Dim lineNumber As Integer
Dim line As String
If selection.IsEmpty Then
selection.StartOfLine(0)
selection.EndOfLine(True)
Else
Dim top As Integer = selection.TopLine
Dim bottom As Integer = selection.BottomLine
selection.MoveToDisplayColumn(top, 0)
selection.StartOfLine(0)
selection.MoveToDisplayColumn(bottom, 0, True)
selection.EndOfLine(True)
End If
selection.LineDown(True)
selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn,True)
selection.Delete()
selection.MoveToDisplayColumn(selection.BottomLine, 0)
selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstText)
End Sub
End Module