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

一些类似的例子:

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


当前回答

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

其他回答

由于我不能在我的Visual Studio 2013中使用宏,我找到了一个Visual Studio插件(我在2012年和2013年使用它)。 重复选择重复选择和整行-他们只需要部分选择。标准快捷键是ALT + 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 2010中,你用CTRL + INSERT复制光标所在的整行,然后你可以用CTRL + V或SHIFT + INSERT粘贴它。

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

我一直在使用Wael发布的宏:Visual Studio的重复行命令,但它一周前就停止工作了,我猜是因为Windows更新。 我是正确的,在2014年2月,宏在VS2010(和2008显然)已经被禁用。

要解决这个问题,您要么必须卸载安全更新,要么向配置文件中添加一行代码,如下所示。

在64位的Windows机器上,这些文件的默认路径是:

C:\Program Files (x86)\Common Files\Microsoft Shared\VSA\9.0\VsaEnv\vsaenv10.exe.config C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.config ... < >配置 运行时> < < AllowDComReflection启用= " true " / > ...

你必须运行你的文本编辑器与管理权限,否则它不会工作!希望这能帮助那些突然有宏功能的人。