在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 Code 2019:
使用ctrl+k和ctrl+s编辑菜单键盘快捷键
编辑“向下复制一行”(Shift + Alt + DownArrow)到你自己的快捷方式。
您可以通过命令ID: editor.action.copyLinesDownAction找到它
对我来说,ctrl+d
其他回答
由于我不能在我的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
I use application link:AutoHotkey with below code saved in CommentDuplikateSaveClipboard.ahk file. You can edit/remove shortcuts it is easy. I have link to this file "Shortcut to CommentDuplikateSaveClipboard.ahk" in Autostart in windows. This script protect your clipboard. If you are more curious you would add shortcuts to thisable/enable script. I sometimes use very impressive Multi Clipboard script to easy handle with many clips saved on disk and use with CTRL+C,X,V to copy,paste,cut,next,previous,delete this,delete all.
;CommentDuplikateSaveClipboard.ahk
!c:: ; Alt+C === Duplicate Line
^d:: ; Ctrl+D
ClipSaved := ClipboardAll
Send, {END}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{END}{ENTER}{CTRLDOWN}v{CTRLUP}{HOME}
Clipboard := ClipSaved
ClipSaved =
return
!x:: ; Alt+X === Comment Duplicate Line
ClipSaved := ClipboardAll
Send, {END}{SHIFTDOWN}{HOME}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{LEFT}//{END}{ENTER}{CTRLDOWN}v{CTRLUP}{HOME}
Clipboard := ClipSaved
ClipSaved =
return
!z:: ; Alt+Z === Del uncomment Line
ClipSaved := ClipboardAll
Send, {END}{SHIFTDOWN}{UP}{END}{SHIFTUP}{DEL}{HOME}{DEL}{DEL}
Clipboard := ClipSaved
ClipSaved =
return
!d:: ; Alt+D === Delete line
Send, {END}{SHIFTDOWN}{UP}{END}{SHIFTUP}{DEL}
return
!s:: ; Alt+S === Swap lines
ClipSaved := ClipboardAll
Send, {END}{SHIFTDOWN}{UP}{END}{SHIFTUP}{CTRLDOWN}x{CTRLUP}{UP}{END}{CTRLDOWN}v{CTRLUP}{HOME}
Clipboard := ClipSaved
ClipSaved =
return
!a:: ; Alt+A === Comment this line, uncomment above
Send, {END}{HOME}//{UP}{HOME}{DEL}{DEL}
return
在Visual Studio 2010中,你用CTRL + INSERT复制光标所在的整行,然后你可以用CTRL + V或SHIFT + INSERT粘贴它。
Ctrl + D是VS 2017 v15.6中引入的一个新快捷键,它的作用似乎和Ctrl + E, V完全一样
Ctrl + D将复制光标所在的行,并将其插入到焦点行的正下方。如果希望复制一组特定的代码,只需在调用duplicate code命令之前选择要复制的代码部分。
它不会影响你的剪贴板
源