在Visual Studio 2008中有复制行命令的快捷方式吗?

一些类似的例子:

在notepad++中,我可以用Ctrl+D复制当前行 在EditPlus中按Ctrl+J 在NetBeans中:Ctrl+Shift+↓/↑ 在Eclipse中,按Ctrl+Alt+↓/↑ Vi/Vim, yyp 等。


当前回答

对于那些在2008年之后还在Visual Studio上查看这个问题的人,一个真正的编辑。副本已添加:

CTRL + E, V Ctrl + d (vs 2017 15.6+)

其他回答

有一个免费的扩展,你可以下载这里,让你复制行无需替换剪贴板的内容。

默认情况下,它被绑定到Alt + D,但你可以通过点击工具->选项->环境->键盘将其更改为任何你想要的。在搜索框中输入“复制”,然后查找“编辑”。DuplicateSelection”,并编辑快捷方式为任何你想要的。我更喜欢Ctrl + D与其他编辑器保持一致。

如果你喜欢使用CTRL+ALT+UP或CTRL+UP+DOWN复制eclipse样式的行(或块),下面我发布了用于此目的的宏:

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

把你的鼠标放在一行复制,然后按CTRL+C,然后按CTRL+V在同一行。 就像魔法一样:-)

在visual studio 2008中,可以使用CTRL + c++ V

对于那些在2008年之后还在Visual Studio上查看这个问题的人,一个真正的编辑。副本已添加:

CTRL + E, V Ctrl + d (vs 2017 15.6+)