Visual Studio 2010 shortcut to go back from definition [duplicate] - visual-studio

This question already has answers here:
After "Go to Definition", is there a command to return to where you came from?
(9 answers)
Closed 9 years ago.
In Visual Studio when going to definition by pressing F12, it takes you to definition. Is there any way to go back to where you came from?
This is specially annoying when you have definition within same file. If it's in another file then it's ok Ctrl+Tab take you back to previous window. But when it's in same file then have to find where you came from and go there.

Try the key combination: Ctrl + -.

As others mention, use Ctrl + -. This is the View-NavigateBackward shortcut in Visual Studio's default key mapping scheme, and can be mapped to any key combination you like from Tools->Options->Keyboard. I like Alt+← myself, to match typical web browser use.
Note that, for most five-button mice, the navigate-left button will also do this.

Ctrl + -

Ctrl -> '+' -> '-'
I searched for a long time till i found that one, and I can't stop using it since!! :)

Related

Can't print } on Visual Studio 2017 on Italian keyboard [duplicate]

This question already has an answer here:
Recent Visual Studio update introduced shortcut used to create closing curly brace on my keyboard: how to find offending command?
(1 answer)
Closed 4 years ago.
When I press the keyboard shortcut CTRL+ALT+SHIFT+] on an Italian keyboard to add a closed curly brace, Visual Studio selects a block of my code instead of printing it.
I have already tried to reset the keyboard mapping on Visual Studio but to no avail.
Other programs works without problems. How can I fix this problem?
It is a new feature appeared in Visual Studio 2017 version 15.8.0.
It is called ExpandSelectionToContainingBlock and it is mapped to the keyboard shortcut CTRL+ALT+SHIFT+] or CTRL+ALT+SHIFT++ (For VS in Italian)
But this mapping has removed the ability, from some keyboards without the key for the closing brace (like the Italian one), to press those keys and get the, indispensable for many programming languages, close curly brace.
As far as I know there are two workarounds
Go to Tools menu and select Customize
Press the Keyboard button
Search for Edit.ExpandSelectionToContainingBlock
Press Remove
or just use the numeric keypad and press
ALT+0125
For Italian readers with the Italian version of VS, the search above at point 3 should be for Modifica.Espandiselezioneabloccocontenitore. I don't know if other languages are affected by this 'translation vice' but it is a thing to be aware of.
The problem has already been reported to MS (Thanks Albireo)
EDIT: It seems that they have fixed the problem, in version 18.5.2 there is anything assigned to the shortcut. But I am not sure if this is an effect of my previous action or if this (no shortcut) is the real default now.

IntelliJ Shift Shift Shortcut in Visual Studio (Global Search)

After doing some Java I fell in love with some of IntelliJ's features. Especially the keyboard shortcut SHIFT +SHIFT which lets you jump to any other file.
This is a huge time savesaver. Now that I'm back in VS I really miss that feature when I'm editing code. Is there any way to reproduce this in Visual Studio? Perhaps a plugin of some sort?
It's became possible after the recently VS Code release(1.54.0 or above), you can update keybindings.json with following code:
[
{
"key": "shift shift",
"command": "workbench.action.quickOpen"
},
{
"key": "alt alt",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl ctrl",
"command": "workbench.action.showCommands"
}
]
Source: https://github.com/microsoft/vscode/issues/5280#issuecomment-767869212
Or install VS Code extension: shift shift
No need for ReSharper since Visual Studio 17 has already implemented a similar feature:
CTRL + T
Not exactly the same (doesn't show the last used/opened tabs), but works to jump to a file (might be VS 2013+ only):
CTRL+, then type your search terms, you can use space for different parts of the file name:
con na ex => ControlNameExplorer
I find it easier to use when disabling the Preview Tab (click on the down arrow at the right of the search box to change settings).
More details here.
EDIT
This shortcut is set when installing ReSharper, but you can manually set it to the command Edit.NavigateTo (Tools > Options > Environment > Keyboard).
EDIT for VS2017
The command is now named Edit.GoToAll. Thanks to Matt for pointing it out.
A few years later and ReSharper now has this feature in the latest version.
It's called Search Everywhere/Go to Type and is triggered with shortcut CTRL + N
https://www.jetbrains.com/help/resharper/Navigation_and_Search__Go_to_Type.html
Extremely useful feature, saves you lots of time and allows you to jump to other files while editing code. Once you try it, using Solution Explorer feels like a waste of time. I got used to it while using IntelliJ IDEA & Android Studio, glad it's now available in Visual Studio via ReSharper.
Not really sure what SHIFT-SHIFT does, does that mean holding down both SHIFT keys and pressing J?
I find I seldom need to goto a file. I put my cursor on a variable or a function, hit F12 and it goes to wherever it is defined, without me needing to remember it. If I press SHIFT-F12 it gives a list of every where it is referenced, again without needing to remember. If I want to go back to where I was at I press CTRL+- (which works in any context). I am quite comfortable with this navigation, and so like you, every time I try something new the first thing I do is try to find out how they implement what I am already used to.

Does VS has any shortcut like ctrl+q in eclipse?

It returns your caret(aka cursor) to the place where you stopped writing code(very useful for fast code browsing)
Ctrl + - will move to the previously browsed line of code (Ctrl + Shift + - will move forward). You can download PDF versions of all the default keybindings in Visual Studio 2010 from this page.
ReSharper has Ctrl+Shift-Backspace to return to previous editing position. Or Ctrl+Shift+, (Comma) to browse some recent edition places.
In addition to what is mentioned in the other answers, you can use the undo/redo trick. As long as you want to navigate to the last edit position in the current file, a quick undo/redo will take you there.
You are looking for View.NavigateBackward. The actual keystroke depends on your personal settings, but it's probably Ctrl + -. If not, go to Tools/Customize/Commands/Keyboard to find out what it is for your setup.
There are ctrl+- and ctrl+shift+- That navigate backward and forward.

VS 2010: How do I get "next tab", "prev tab" keyboard shortcut working? [duplicate]

This question already has answers here:
Changing Ctrl + Tab behavior for moving between documents in Visual Studio
(14 answers)
Closed 9 years ago.
How do I get "next tab", "prev tab" keyboard shortcuts to work in Visual Studios 2010?
(For a more precise description of the functionality I need please see the firefox/chrome/etc and how they do their "ctrl-pgdn" and "ctrl-pgup" keyboard shortcuts).
This should be extrememly easy... and yet I can't seem to figure it out.
NOTE:
I do know that there is a "ctrl-tab" that is similar... but it only scrolls through the "most recently used list" which is different. I don't care about "the most recently used list". I just want to go to the right/left tab.
You should map the Window.NextDocumentWellTab and not View.NextTab and remove it from any other functions its assigned to. Only mapping it will not work, you also need to unmap from anything else its being used on, apparently.
This is what my keyboard configuration looks like:
Looked into this some more, and it turns you need to install the Productivity Tools. That gives you that NextDocumentWellTab function.
Under Visual Studio 2010 Professional, this keyboard shortcut goes by the name Window.PreviousDocumentWindow and Window.NextDocumentWindow.
Important Note: By default, Ctrl-PgUp and Ctrl-PgDown are assigned to Edit.ViewTop and Edit.ViewBottom respectively, so make sure to remove the existing keyboard assignment before trying out your new assignment. If you don't, the keyboard commands you enter will continue to be interpreted as the most "specific" shortcut (Edit.ViewTop or Edit.ViewBottom) since you're most likely trying this out in the Edit view!

Visual Studio equivalent to Delphi bookmarks

I use Delphi for many years, and although I have now moved on to Visual Studio I still fondly remember numbered bookmarks (CTRL+K+1 to set bookmark 1, CTRL+Q+1 to goto bookmark 1).
Is there a Visual Studio equivalent? I'm find the dumb bookmarks in VS a chore after Delphi. I want to bookmark then return to a specific place in the file.
DPack can give you numbered bookmarks in VisualStudio.
Ctrl K + Ctrl K - Add/Remove Bookmark on Line
Ctrl K + Ctrl N - Go to Next Bookmark
Ctrl K + Ctrl P - Go to Previous Bookmark
There are other options as well. Look under Edit->Bookmarks menu,
More a comment on your original question than an actual answer but Delphi has had much easier to remember (and type) keyboard shortcuts than what you quote available for quite some time now:
Set bookmark 1: Ctrl-Shift-1
Go to bookmark 1: Ctrl-1
If you ever go back to Delphi, this should make your life so much easier! ;)
Just to amplify Lars Truijens answer. DPack is a GExperts like plugin for visual studio. I found it great help when moving from the Delphi IDE to Visual Studio.
I find this one also very useful:
CtrlK + CtrlL - Clear alll bookmarks
There is a Bookmark Window. Go to menu View/Bookmark Window (Ctrl+K, Ctrl+W).
In there you can see all your bookmarks and rename them. That is a lot better than just seeing the numbers.
For some reason they don't allow to order that list by clicking in a column header, but you can drag the bookmarks and accommodate them in the order you want.
VSBookmarks gives something like the fantastic Delphi bookmarks feature. Tested and works in Visual Studio 2019.
Extensions > Search "VSBookmarks" (v1.7 at time of writing)
Install and restart Visual Studio
Use Ctrl + Shift + N to set a bookmark
Use Ctrl + N to move to a previous bookmark
There will likely be conflicts with existing keyboard shortcuts. To view and edit these:
Tools > Options > Environment > Keyboard
In "Press shortcut keys" type Ctrl + Shift + 1
See which command(s) are currently assigned to the shortcut
Find the command in the list and remove the shortcut
Repeat for Ctrl + Shift + 1 through Ctrl + 9
VSBookmarks applies only within the current file (which is the Delphi behaviour), but is not configurable with just a single colour for the bookmark.
Delphi is an awesome language and editor. Thanks to Sergey Vinyar and Alessandro Fragnani (for the Numbered Bookmarks extension in Visual Studio Code) for keeping the flame alive.
I use:
CTRL-F2 toggle bookmark
F2 next bookmark
SHIFT-F2 previous bookmark
CTRL-SHIFT-F2 clear all bookmarks
BTW, after using Visual Studio for years I just found about a couple of months ago that you can press ALT and drag mouse to mark a column or a square.

Resources