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?
In Visual Basic code files, use these commands to move the insertion point to different methods. Choose Edit > Next Method or Edit > Previous Method.
1. Jump to previous cursor position functionality. In Microsoft Visual Studio there is a shortcut key for navigating to last cursor position (ctrl + -).
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).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With