Is there a shortcut for Duplicate Line command in Visual Studio 2008?
Some similar examples:
While I realize this is not a keyboard shortcut, I figured I would add this, as it does not require the usage of the clipboard and might help some people.
Highlight the row you want to duplicate. Press control, mouse click the highlighted text, and drag to where you want to go to. It will duplicate the highlighted text.
in VS2019 and also in VS2017 you can select Tools->Options->Keyboard and you can choose in the scheme drop-down Resharper (Visual Studio) option, and you will get a mapping like if you were using Resharper, in this case Ctrl + D will do the trick for duplicating the line. Anyways, based on the documentation this should be out of the gate in Visual Studio 2017 Version 15.8 or greater
Ctrl + D works for me in VS2012 with Resharper. It's Resharper's hot key.
For Visual Studio Code 2019:
Edit menu keyboard shortcuts with: ctrl+k and ctrl+s
Edit "Copy Line Down" (Shift + Alt + DownArrow) to your your own shortcut.
You can find it, with the command ID: editor.action.copyLinesDownAction
For me, It's ctrl+d
Visual Studio Code : May 2020 (version 1.46) Shift + UpArrow/DownArrow : To Duplicate the line of code
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