Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigating backward and forward with the mouse in Visual Studio 2008

My install of Visual Studio 2008 does not support IE style back and forward navigation withe the mouse in the C# code editor.

Searches show that multiple people have run into this problem but I have yet to find a correct solution.

There's even a VS add-in hack just to work around the "bug".

Any idea why this functionality fails for some users and how to fix it?

like image 347
Todd Smith Avatar asked Jan 08 '09 19:01

Todd Smith


People also ask

How do you move forward and backward in Visual Studio?

By default, Alt+Left navigates back, and if you remove the Alt+Right shortcut for Edit. CompleteWord in Microsoft Visual Studio, Alt+Right navigates forward.

How do I navigate in Visual Studio?

You can use the navigation bar (the drop-down boxes at the top of the code window) to navigate to code in a codebase. You can choose a type or member to go directly to it. The navigation bar appears when you edit code in a Visual Basic, C#, or C++ code base.

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

Navigate Forward/Backward Ctrl+–/Ctrl+Shift+– If you've moved from one location to another you can use the keyboard sequence <Ctrl>+– to move to the previous location and then you can return using Ctrl+Shift+–.


1 Answers

You can mitigate the problem by AutoHotKey tool (free, open source).

Let's assume your Visual Studio 2008 has these editor commands and their respective shortcuts:

  • View.NavigateBackward = Ctrl+-
  • View.NavigateForward = Ctrl+Shift+-

You should be able to verify these shortcuts in keyboard options. Verified? Let's proceed.

So will you be just fine if your mouse will send these keyboard shortcuts if the Visual Studio's main window is active?

Then install the tool and add the following two mappings:

XButton1::^-
XButton2::^+-

These correspond to above keyboard shortcuts: ^ = Ctrl, + = Shift, - = -

Using AutoHotKey icon in notification area, reload definition file you just updated. Now your mouse buttons should produce the above shortcuts. Test them. If they work for you in Visual Studio editor, you can limit them only to Visual Studio main window, otherwise they work across the entire desktop:

SetTitleMatchMode, RegEx
#IfWinActive, .*- Microsoft Visual Studio

XButton1::^-
XButton2::^+-

#IfWinActive

Feel free to adjust title-matching regex if needed.
Do not forget to reload definitions file to apply any changes you made.

Bonus:
And here are some other handy operations if you are holding Shift or Ctrl:
(You have those mouse buttons, let's use them... for commands across the entire desktop.)

+XButton1::^c
+XButton2::^v
^XButton1::^x
^XButton2::^z

(Letters must be lowercase, because uppercase means Shift+letter.)
(And always make sure you are running AHK elevated (as administrator.))

Enjoy!

like image 82
miroxlav Avatar answered Oct 08 '22 06:10

miroxlav