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

一些类似的例子:

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


当前回答

Ctrl + D是VS 2017 v15.6中引入的一个新快捷键,它的作用似乎和Ctrl + E, V完全一样

Ctrl + D将复制光标所在的行,并将其插入到焦点行的正下方。如果希望复制一组特定的代码,只需在调用duplicate code命令之前选择要复制的代码部分。

它不会影响你的剪贴板

其他回答

http://www.jetbrains.com/resharper/

我的故事:开始在一家新公司工作,以前从未使用过Visual Studio。第一件事之一,如何复制线条。设置宏后ReSharper告诉我:你想取代我的快捷方式是:“复制文本”:)

不是答案,只是一个有用的补充: 作为免费赠品,我刚刚发明了(嗯……记得不能用调整由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

VS 2017的Ctrl + D或Ctrl + C;Ctrl + V 他们都为我工作。

为什么要用这么长的方法来完成这么简单的事情?它需要不到一分钟的时间从微软下载和安装扩展。该页面说它将默认绑定到ALT+D,但对我来说,它在Visual Studio Community 2015中自动绑定到CTRL+D,没有任何更改。

这里是从Microsoft.com下载扩展的链接。

在Visual Studio 2013中,可以使用Ctrl+C+V