Is there a shortcut for Duplicate Line command in Visual Studio 2008?
Some similar examples:
In visual studio code (WebMatrix):
Copy Lines Down: Shift + Alt + down
Copy Lines Up: Shift + Alt + up
Delete Lines: Ctrl + Shift + k
In Visual Studio 2010 you copy the entire line the cursor is on with CTRL + INSERT then you can use Ctrl + V or SHIFT + INSERT to paste it.
Why so many long drawn out methods to accomplish something so simple? It takes less than a minute to download and install the extension from Microsoft. The page says that it will bind it to ALT+D by default, but for me it bound it to CTRL+D automatically in Visual Studio Community 2015 without any changes.
Here's the link to download the extension from Microsoft.com.
I've been using the macro that Wael posted: Duplicate line command for Visual Studio, but it stopped working a week ago, I assumed because of a Windows update. And I was correct, as of February 2014, Macros have been disabled in VS2010 (and 2008 apparently).
To fix this you'll either have to uninstall the security updates, or add one line of code into the config files as shown here.
On a 64-bit Windows machine default paths to these files are:
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
...
<configuration>
<runtime>
<AllowDComReflection enabled="true"/>
...
You MUST run your text editor with admin rights or it won't work! Hopefully this helps anyone else who suddenly has their macro functionality pulled out from underneath them.
In Visual studio 2017 and maybe other version No need Macro or Extension,
Tools > Options > Environment > Keyboards
Show commands containing:
write Edit.Duplicate
Press shortcut keys:
and press Ctrl + D and click Assign
buttonOK
to save your new keyboard shortcutI don't know if this exists in Visual Studio 2008 but in Visual Studio 2010+ you can easily do this by:
Don't select anything, then press Ctrl + C And then (without doing anything else) Ctrl + V