在Visual Studio 2008中有复制行命令的快捷方式吗?
一些类似的例子:
在notepad++中,我可以用Ctrl+D复制当前行 在EditPlus中按Ctrl+J 在NetBeans中:Ctrl+Shift+↓/↑ 在Eclipse中,按Ctrl+Alt+↓/↑ Vi/Vim, yyp 等。
在Visual Studio 2008中有复制行命令的快捷方式吗?
一些类似的例子:
在notepad++中,我可以用Ctrl+D复制当前行 在EditPlus中按Ctrl+J 在NetBeans中:Ctrl+Shift+↓/↑ 在Eclipse中,按Ctrl+Alt+↓/↑ Vi/Vim, yyp 等。
当前回答
在Visual studio 2017或其他版本不需要宏或扩展,
进入“工具>选项>环境>键盘” 在显示命令下包含:写编辑。重复的 将光标置于“按快捷键:”,按“Ctrl + D”,单击“分配”按钮 单击OK保存新的键盘快捷方式
其他回答
把你的鼠标放在一行复制,然后按CTRL+C,然后按CTRL+V在同一行。 就像魔法一样:-)
Visual Studio Code: 2020年5月(版本1.46) Shift +向上/向下箭头:复制代码行
下面是一个基于Wael发布的链接的宏,但在以下方面进行了改进:
稍短的 稍快 评论:) 以"///"开头的行。 可以用一次撤消撤消吗
Imports System
Imports EnvDTE
Imports EnvDTE80
Public Module Module1
Sub DuplicateLine()
Dim sel As TextSelection = DTE.ActiveDocument.Selection
sel.StartOfLine(0) '' move to start
sel.EndOfLine(True) '' select to end
Dim line As String = sel.Text
sel.EndOfLine(False) '' move to end
sel.Insert(ControlChars.NewLine + line, vsInsertFlags.vsInsertFlagsCollapseToEnd)
End Sub
End Module
不是答案,只是一个有用的补充: 作为免费赠品,我刚刚发明了(嗯……记得不能用调整由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
在visual studio 2008中,可以使用CTRL + c++ V