VS2010 Hotkey Name for Duplicating Line - visual-studio-2010

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 :)

This can be done by creating Macro. To create the macro, follow these steps.
Go to the macro explorer (Tools->Macros->Macro Explorer)
Right Click My Macros and click New Module.
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:
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.)
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
Hit the OK button
*Source: * http://www.herrodius.com/blog/52

Related

Is there any shortcut for CodeBlocks to format the code?

Is there any shortcut for CodeBlocks to format the code?
I haven't find any tip in google.
I found only "format use AStyle", but it come up with right mouse button only...
probably not by default but you should be able to assign it there:
Settings -> Editor -> Keyboard shortcuts -> Plugins -> Source code formatter (AStyle)
My favourite = Ctrl + A then Ctrl + Shift + F.
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.
So for indenting a whole file: Ctrl + A, then Tab.
In addition, you can use Shift + Tab on a selected block to "unindent"
You can move through the open tabs with Ctrl + Shift + Tab.
As for the best shortcuts:
I like Ctrl + D to duplicate a line and
Ctrl + L to copy it.
Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).

Can I disable or change a single ReSharper shortcut?

I am using VS 2010 and there is one shortcut I really like which is a shortcut I set myself: ctrl + shift + Q in order to remove all unused usings and sort the remaining ones.
I installed ReSharper and it overwrote my VS shortcuts, so pressing ctrl + shift + Q will generate a comment (/**/).
Is there any way I can disable this single shortcut? (or change it to any other key combination that will allow me to use my old one?
I tried this solution: How to change shortcut keys for a given command in ReSharper? but my shortcut is still set in my VS configs.
Go to Tools > Options > Environment > Keyboard
Search for a command called ReSharper.ReSharper_BlockComment
Remove the current shortcut or reassign another shortcut to the ReSharper command.
I'm guessing that you've set your shortcut in Global context whereas ReSharper has assigned the shortcut to its command in the Text Editor context. The latter takes precedence when you're invoking the shortcut while editing your code.
Also, consider taking a look at ReSharper's own Code Cleanup, which takes care of unused directives, other redundant items, and formatting.
To elaborate on the steps:
Suppose you want to change the binding of "Ctrl +Q"
Open Tools Options Environment Keyboard
Under "Press Shortcut Keys" Enter : Ctrl +Q
This will show you what all commands are currently bound to this shortcut
Then search for the commands in the "Show Commands containg window " and REMOVE the assignment (for the context that you want).
Note that more than 1 command can bind to a shortcut depending on the context and so make sure you remove whatever you need
Then verify that no the binding is gone, by repeating step 2 above
Finally search for the new command that you want to bind the shortcut to and then enter shortcut and bind it in the context that you want to using ASSIGN

What is the fastest way to jump to a constructor(s) in a class?

I’m using Visual Studio 2010, with Resharper. Many classes in my project are very big and I wonder if there is a shortcut to jump between constructor(s) of my class.
You can use Resharpers Goto File Member which is Alt + \
The constructor seems to be always on top of the list, so you just need to Alt + \ and Enter to go to the constructor of the current class.
With Resharper there is also "blind" way.
Like l.poellabauer said by using Goto File Member which is Alt + \ , But You can type there 'ctor', that will display classs constructors with first one selected. So just press Enter or select desired constructor with Up/Down and go navigate to it.
I am not aware of any shortcut for reaching constructors, but if you are instantiating a class with new (e.g. new A() ), you can reach to constructor of A by pressing F12 or selecting "Go to Definition" on A().
I'dont know a shortcut, but resharper has a window called 'File Structure' (you will find under ReSharper -> Windows -> FileStructure'. This window shows all the methods, ... and constuctors have a special icon an most commonly constructors at the top of each class file. Give them a try.
With Resharper 2019.2:
Ctrl + F12 to show the "members" search box
Type "ctor"
The construcutor(s) will be filtered and selected
Select and press Enter
Note: This is using the ReSharper 2.x or IntelliJ IDEA keyboard scheme (ReSharper > Options > Environment > Keyboard & Menus > Keyboard Shortcuts)

Shortcut for Replace button in "Find and Replace" dialog

I call up Find and Replace dialog with Ctrl+H. On F3 it finds the result but then I must hunt the Replace button using the mouse. And on every new find, it changes the screen position. Is there any way to use this dialog using only keyboard?
It will save me a few precious seconds multiplied by some very large number (I'm in the middle of heavy refactoring).
In visual studio 2015:
Ctrl+H opens the Replace dialog.
Ctrl+F opens the Find dialog.
Within that dialog:
Alt+N - Focus "Find" entry field
Alt+P - Focus "Replace with" entry field
Alt+C - Toggle Match Case
Alt+W - Toggle Whole Word
Alt+E - Toggle Regular Expressions
Alt+L - Open "Look In" dropdown list. Use Up/Down and Enter to select from this list:
Current Block
Selection
Current Document
All Open Documents
Current Project
Current Solution
Alt+R - Replace Next
Alt+A - Replace All
Esc - Dismiss dialog
For example, to replace "foo" with "bar" within the current selection:
Ctrl+H - Opens the Replace dialog, with focus on "Search Term".
Enter "foo"
Alt+P - Focus is now on "Replacement Term"
Enter "bar"
Alt+L, choose "Selection", press Enter.
Alt+W - Whole word only
Alt+R - Replace first term
Esc - Close replace dialog.
Sorry,
As microsoft there is no keyboard shortcut as Replace Next,
You can check this url
http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx
You could simply copy your desired replacement text before starting to F3 through your source text, and hit Ctrl+V when you hit the next match as VS selects the match text for you.
It is a hack, but it works.
If you dock the find/replace window then it will not move with each new find.
You can then alternate with 1 finger on F3 to move to next find, while hovering the mouse over the non-moving replace button to replace what you need.
It is possible to deactivate Resharper default behavior of "Alt+R" which provides a quick access to Resharper menu in Visual Studio.
Just uncheck it in Resharpers options:
enter image description here

"Right Click" keyboard short cut for Visual Studio?

I'm trying to force myself to use as little mouse as possible and I can't find the answer to this simple short-cut anywhere! Here the the steps:
Open up Visual Studio. Open any C# file (or any code file I believe)
Point your mouse anywhere on the
window/file.
Right Click
Is there a shortcut key for this so I don't have to move my hand to the mouse?
Taken from lytebyte, you've got two options:
Shift + F10
That nutty key on the bottom-right of a modern Windows keyboard, the Menu key
Depends on where/why you're right-clicking.
The context-menu key is on the right of the keyboard nowadays, usually between the Windows key and the Control key on the right of your spacebar. That will open the context menu wherever the current focus is (usually in the text editor).
If you're using the right mouse button just to open the refactoring tools, you can use Ctrl + . (control period) to pop open the "smart tag" on any identifier. That'll get you the "generate method stub" menu item and the like.
To open a new file without keyboard you can use
CTRL + SHIFT + N (Using Resharper)
To show up the right click menu for any part of your code. Point to the part that you want and use
SHIFT + F10
Normally, I like using
CTRL + SHIFT + G (Resharper again)
for getting the Navigation menu (Usage, Base, Implementation, etc)
Even better if you want to go to any Method/class/intenal/or a field, use CTRL + SHIFT + ALT + N (Again using Resharper), this will bring you a list of all that match your criteria to choose from.
Does your keyboard have the extra 'Windows' keys, ie. the Windows logo (Start key) and the one on the right-hand side of the spacebar that looks like a menu? Cause that button on the right-hand side is the 'Context menu key'.
See the key between the right-hand side 'Windows' key and the Ctrl key?
Windows Keyboard layout
If your keyboard is less than 10 years old you should have these keys, unless you have an IBM laptop or a Mac.!
Assuming you just want a key you can press to right click, most\many keyboards have a key between alt and ctrl that right clicks.

Resources