JREAM
JREAM

Reputation: 5941

VS2010 Hotkey Name for Duplicating Line

In Visual Studio 2010 what is the hotkey binding name for duplicating a line in the keyboard editor? I want to change it from

 CTRL + C / CTRL + V 

to

CTRL + SHIFT + DOWN

Then I can be happy and content :)

Upvotes: 0

Views: 64

Answers (1)

Hary
Hary

Reputation: 5818

This can be done by creating Macro. To create the macro, follow these steps.

  1. Go to the macro explorer (Tools->Macros->Macro Explorer)
  2. Right Click My Macros and click New Module.
  3. In the module created copy and paste the code.

    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
    

Now just assign a keyboard shortcut to it:

  1. Go to Tools->Options
  2. Under Environment, click Keyboard
  3. In the "Show Commands Containing" textbox, enter "duplicate" (this according to the name you gave the module.)
  4. Choose "Text Editor" from the "Use new shortcut in" list
  5. 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)
  6. Hit the "Assign" button
  7. Hit the OK button

*Source: * http://www.herrodius.com/blog/52

Upvotes: 1

Related Questions