在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 2013中使用宏,我找到了一个Visual Studio插件(我在2012年和2013年使用它)。 重复选择重复选择和整行-他们只需要部分选择。标准快捷键是ALT + D。
其他回答
在Visual Studio 2022中
Ctrl + E, V
在Visual Studio 2019中
Ctrl + D
在Visual Studio 2017 (v15.6及以后版本)中
Ctrl + D
在Visual Studio 2017 (pre v15.6)
(编辑)这个功能现在是内置在VS2017: Ctrl + E, V复制一行,如果没有选择,或重复选择。你可以将它分配给不同的键组合,或者在菜单中找到它:
有关更多信息,请参阅此参考资料。
Pre VS2017,内置方法使用剪贴板
正如@cand提到的,你可以按Ctrl + C;Ctrl + V。
如果没有选择,Ctrl + C将复制该行。
宏观解决方案(VS2017前期)
如果你想实现一个更完整的解决方案,也许是创建一个更简单的键盘快捷键,或者你不想影响剪贴板,请参阅以下指南:
Visual Basic: Imports System Imports EnvDTE Imports EnvDTE80 Imports System.Diagnostics Public Module DuplicateLastLineModule Sub DuplicateLine() Dim line As String DTE.ActiveDocument.Selection.StartOfLine(0) DTE.ActiveDocument.Selection.EndOfLine(True) line = DTE.ActiveDocument.Selection.Text DTE.ActiveDocument.Selection.EndOfLine() DTE.ActiveDocument.Selection.NewLine() DTE.ActiveDocument.Selection.StartOfLine(0) DTE.ActiveDocument.Selection.Text = line End Sub End Module To create the macro, just go to the macro explorer ("Tools->Macros->Macro Explorer" or Alt+F8) and copy paste the code in a new module. Now just assign a keyboard shortcut to it: go to Tools->Options... under Environment, click Keyboard in the "Show Commands Containing" textbox, enter "duplicate" (this according to the name you gave the module.) you should now see the macro in the list below choose "Text Editor" from the "Use new shortcut in" list set focus in the "Press shortcut keys" textbox and hit the combination on the keyboard you wish to use for it (Ctrl+Shift+D in my case) hit the "Assign" button you should now see the shortcut in the "Shortcuts for selected command" textbox hit the OK button And that's it. Enjoy!
Visual Studio Code: 2020年5月(版本1.46) Shift +向上/向下箭头:复制代码行
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代码(WebMatrix)中:
向下复制行:Shift + Alt +向下
复制线:Shift + Alt +向上
删除行:Ctrl + Shift + k
简单的Ctrl + C;Ctrl + V,检查一下 链接。只要你不选择任何文本,当你按Ctrl+C时,这将复制光标所在的行。