What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio? - visual-studio

In Eclipse, selecting a line and pressing Alt + ↑/↓ will move the line up and down, a quick way to avoid copy&paste.
Is there an equivalent in Visual Studio?

In Visual Studio 2013 and later, this functionality is built in. ALT + UP/DOWN will move a line up or down.
If you need this functionality in VS2012 (works with VS2010 too), take a look at the MoveLine Visual Studio Extension or the Productivity Power Tools suite.

ReSharper's Ctrl + Shift + Alt + ↑/↓/←/→ is even more powerful - when on the beginning of the line, it will move the entire line, but can also be used to move entire methods, change the order of parameters, etc.

For me in Visual Studio 2019 it comes default closed.
For open it:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesUp, click "Press shortcut keys" input and press Alt + Up (or whatever you want for it). And the other one is Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down (or whatever you want for it).

This is now working out of the box with Visual Studio 2013, same way as in Eclipse.

For Visual Studio 2013:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down. You also have to select the scope of the shortcut to be within "Text Editor".

In Visual Studio 2013 and later, you can move lines up and down using Alt + ↑ / Alt + ↓. Unfortunately this will not adjust the indentation if you move between blocks, as of today only ReSharper (and all other IDE's by Jetbrains including Rider) can help you with that.
To move entire blocks of code around you can move the cursor to its head and press Ctrl + m twice fast to collapse it, and then use the command above to move it around.
Here is a neat reference to all default keyboard shortcuts in different versions of Visual Studio.

With the VSCommands extension, you have exactly that keyboard shortcut. And, by the way, a Stack OVerflow notification toolbar :)

Related

How to replicate SublimeText ctrl+D in Visual Studio

I am used to work with Sublime text and trying to switch for Visual Studio for bigger projects, one of the feature of sublime that I absolutely love is its multiple select feature. You can hit ctrl + d multiple times to select next instance of the same word and then rewrite them all at once. Is there anything like this in Visual studio? I tryed to find it, but with no success.
Btw I am using Visual Studio 2015.
Visual studio 2017-19
The default shortcut is Alt+Shift+.
But if you want to add Ctrl+D
Go to the menu Tools > Options then select the Keyboard tab on the left
At the top you'll find an option to add extra keybindings, select Visual Studio Code. Save and That's it!
This works because Visual Studio Code has Ctrl+D, and other shortcuts similar to SublimeText
Alternatively you can manually add shortcuts
In the image, you can find any command to customize in the middle section.
The particular command you are interested is the one selected Edit.InsertNextMatchingCaret
Ctr R, R, this is used to replace the name of the varibals, depronto can serve it.
and you are encouraged here are all the shortcuts of vs2015 http://visualstudioshortcuts.com/2015/
Goto Tools / Options / Keyboard
Search for duplicate
Choose Edit.Duplicate
Remove the assignement for the current shortcut
Assign the shortcut you want
Ctrl + Shift + L seems to work.
Use Alt +leftClick and ctrl+F2 . For more reference you can go Official Website [link]https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference
I decided to use this Visual Studio Extension:
https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.SublimeVS

Create Visual Studio Keyboard Shortcut that include Mouse Click

Is it possible to create a short cut in Visual Studio that includes a left mouse click?
Currently, Ctrl + Left Click short cuts to Go to Declaration.
I'd like to map Ctrl + Shift + Left Click to Go to Implementation.
I know I can create a keyboard only shortcut, but I'd like to include the mouse.
From what I know this is not supported by default in Visual Studio.
You can have Ctrl + Alt + Left Click to go to implementation with ReSharper.
Using ReSharper you have an option for this in ReSharper options:
ReSharper is a paid extension that brings a lot of great features to Visual Studio. I'm not affiliated in any way with ReShaper. I'm just a fan of the extension.

Visual Studio shortcut for "quick fix"

Does Visual Studio 2010 have a shortcut for quick fix?
I'm tired of grabbing the mouse, hovering over this red line, waiting for the little clipboard icon to appear, clicking on the first menu item. It would be so much fast to just open that dialog with some keys and confirming the first (i.e. selected) item.
The feature is called the "Smart Tag".
Default Keyboard Shortcut Schemes (ReSharper documentation)
Stack Overflow question How does one set Visual Studio 2010 keyboard shortcuts comfortably, especially when using ReSharper?
Stack Overflow question Visual Studio keyboard shortcut to automatically add the needed 'using' statement
They can usually be invoked via the keyboard using either:
Ctrl+. (on a standard QWERTY keyboard)
Alt+Shift+F10 (if you've not got Function Lock enabled)
If your cursor is on the item that is underlined, you can use Ctrl + . to pop up the intellisence/suggestion context menu.
Alt + Shift + F10 does the trick.
Via #Rohit from Visual Studio keyboard shortcut to automatically add the needed using statement
If you want to edit the shortcut of quick fix you can do the following:
Open Tools->Options->Keyboard and in the Show commands containing field enter EditorContextMenus.CodeWindow.QuickActionsForPosition and replace the old shortcut with the new one.

Shortcut for "Find Result 1" in Visual Studio?

Shortcut for "Find Result 1" in Visual Studio?
Hotkeys for Visual Studio 2010 - Alt + vn1
Hotkeys for Visual Studio 2015 - Alt + vnnEnter1
Hotkeys for Visual Studio 2017 - Alt + vnnnEnter1
If you don't feel like customizing your own shortcuts, or you use different environments where you can't always rely on your customization being present, you can always go the old school route of just navigating the menus via hotkeys.
For instance, in Visual Studio 2010, you can just type Alt + vn1.
Typing Alt + v opens up the "View" menu.
Typing n opens up the "Find Results" menu item in the View menu.
Typing 1 selects the "Find Results 1" menu item, thereby opening and setting focus to the "Find Results 1" window.
Likewise, Alt + vn2 opens up the "Find Results 2" window.
If you do this enough, it's like any other keyboard shortcut, and becomes second nature.
ProTip
You can discover the hotkey shortcut to any menu item you need by just hitting Alt, and looking at the letters that are underlined in the menus. This applies to pretty much any windows program you will ever use.
There's no predefined shortcut for that (at least in VS 2005) but just select Customize... from the Options menu, press the Keyboard... button and then create a suitable shortcut for View.FindResults1.
In Visual Studio Professional 2013 (not sure about the other version) the function key "F8" will take you to the next result in the Find Results window, and "Shift-F8" will take you in the reverse direction (i.e. find previous result).
You can assign keyboard shortcuts as you please through Tools > Customize > keyboard.
In the show commands containing textbox type View.FindResults1.
In the Press shortcut keys textbox type in the shortcuts you want to add and then press the Assign button.

Visual studio or resharper shortcut to close currently selected file in IDE

Is there a shortcut in VS 2005 or resharper to close the current file. or "save and close" would be even better
Ctrl + F4
Save and close would
Ctrl + S followed with Ctrl + F4
Visual Studio 2015 + Resharper
The question is a bit old. Just wanted to update it with the current solution.
As you can see below, you can also completely customize your shortcuts:
just navigate to Tools > Options
on the left pane, go to Environment > Keyboard
now use the field Show commands containing to search for file.close
select File.Close on the list
click the field Press shortcuts keys
type your desired shortcut, for example, <Ctrl> + W
finally, click Assign
And you're good to go!
Ctrl+S, Ctrl+F4 will save and close the current file.
Tools -> Options -> Keyboard
Find "Windos.CloseDocumentWindow"
And for me, need to set "Use new shortcut in" to "text editor" to override old ctrl+w without delete

Resources