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

一些类似的例子:

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


当前回答

由于我不能在我的Visual Studio 2013中使用宏,我找到了一个Visual Studio插件(我在2012年和2013年使用它)。 重复选择重复选择和整行-他们只需要部分选择。标准快捷键是ALT + D。

其他回答

对于Visual Studio Code 2019:

使用ctrl+k和ctrl+s编辑菜单键盘快捷键

编辑“向下复制一行”(Shift + Alt + DownArrow)到你自己的快捷方式。

您可以通过命令ID: editor.action.copyLinesDownAction找到它

对我来说,ctrl+d

您需要的命令是Edit.Duplicate。它被映射到CtrlE, CtrlV。这不会覆盖你的剪贴板。

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

默认情况下,它被绑定到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

在Visual studio 2017或其他版本不需要宏或扩展,

进入“工具>选项>环境>键盘” 在显示命令下包含:写编辑。重复的 将光标置于“按快捷键:”,按“Ctrl + D”,单击“分配”按钮 单击OK保存新的键盘快捷方式