Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio IDE - return to previous

In VS2008, is there a way to return to the cursor’s previous position after pressing F12 to jump to a function definition? I know this is possible with some add-ons, but if there a way to get the core product to do this?

like image 835
Paul Michaels Avatar asked Jun 23 '10 12:06

Paul Michaels


People also ask

How do I go back to the previous method in Visual Studio?

In Visual Basic code files, use these commands to move the insertion point to different methods. Choose Edit > Next Method or Edit > Previous Method.

How do I go to previous cursor in Visual Studio?

1. Jump to previous cursor position functionality. In Microsoft Visual Studio there is a shortcut key for navigating to last cursor position (ctrl + -).


2 Answers

Ctrl+- should do the trick which is the standard keyboard shortcut for Navigate Backwards. Or using the navigation buttons in the standard toolbar.

This is explained on MSDN at https://blogs.msdn.microsoft.com/zainnab/2010/03/01/navigate-backward-and-navigate-forward/

On this MSDN page, you can see the following explanations

The editor remembers locations when you move in a single command more than several lines away from where you are currently working, or if you edit in a particular location that is not adjacent to the last place you edited.

The goal is to remember interesting locations so that you can recall where you have been working without remembering so many locations the feature is not useful (such as every character typed, or every line entering several new lines of code one right after the other).

like image 142
PMN Avatar answered Oct 20 '22 04:10

PMN


There was a command which did exactly you asking for: View.PopBrowseContext. It always returns you to the very place where you have pressed F12. It doesn't take in account any movements or edits you did after you have pressed F12.

By default in C# layout it is mapped to Ctrl+Chift+8, but you can assign it to any hotkey you want.

BTW, in VS2015 they decided to get rid of this command.

Update: The extension I've made to emulate this command is available on the marketplace now: PopContext.

like image 22
SergeyT Avatar answered Oct 20 '22 03:10

SergeyT