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

一些类似的例子:

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


当前回答

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

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

其他回答

不是答案,只是一个有用的补充: 作为免费赠品,我刚刚发明了(嗯……记得不能用调整由Lolo发布的代码)RemoveLineOrBlock宏。享受吧!

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

简单的Ctrl + C;Ctrl + V,检查一下 链接。只要你不选择任何文本,当你按Ctrl+C时,这将复制光标所在的行。

Visual Studio Code: 2020年5月(版本1.46) Shift +向上/向下箭头:复制代码行

如果你有一个macos版本,cmd+shift+D可以帮你完成这项工作

在VS2019和VS2017中,你可以选择工具->选项->键盘,你可以在方案下拉Resharper (Visual Studio)选项中选择,你会得到一个映射,如果你使用Resharper,在这种情况下,Ctrl + D将完成复制线条的技巧。无论如何,根据文档,这应该在Visual Studio 2017 Version 15.8或更高版本中推出