Blogs

Rory Becker - DevExpress CodeRush Blog

CodeRush Tip – Enhance Standard VS Navigation

     

How many times have you hit Ctrl+Home or Ctrl+End (to navigate to the start or end of a file), only to realize mere seconds later, that you forgot to copy something to the clipboard before you left.

Now you have to find where you were, copy the code you were after, and then jump back.

There are several ways to get back to where you were:

  • Remember some snippet of code in the vicinity of where you want to be, and use VS’s find window.
  • Remember the name of the method you were in, and navigate to it using Quick Navigation, then locate the code within the method.
  • Page Up or Down to the location of your code. Scanning whole pages of code as you go in case you miss it.
  • Reach for the mouse and use the vertical scrollbar. While many people don’t like the mouse, this does give finer grain control than Page Up and Down.
  • Remember the exact line you were on and use Goto line (Ctrl+G)
  • View.NavigateBackward (See alternatives section after summary)

Wouldn’t it be great if you’d already dropped a CodeRush Marker before you left. That way you could just hit Esc and CodeRush would bring you back to where you were. It would even arrange the view the way it was before you left and restore the selection. Then you could copy the value you needed and return to whichever end of the file you wanted to.

Configuration

Actually setting this up is very simple. We’re going to use the exact same technique from when we Enhanced Studio's Find Command

  • Create a new shortcut (Details here)
  • Set key 1 to Ctrl+Home
  • Set command to MarkerDrop
  • Check the checkbox that says “after executing this command, pass shortcut to IDE for default handling
  • Set context to Focus\Documents\Source\Code Editor
  • Right Click this new shortcut
  • Select Duplicate Shortcut
  • Select the Duplicate
  • Change key 1 to Ctrl+End
  • Click Ok.

…and you’re done.

Summary

All you really need to understand having done this is that you can now visit the top or bottom of a file (via Ctrl+Home or Ctrl+End) and then easily revisit the location you came from, by hitting Esc.

Alternatives

There are those that will point to the built in visual studio View.NavigateBackward (Alt+Left) function. However this command is for me, somewhat less useful. It does not restore my view to how it was before. It does not restore the selection and it does not provide any kind of locator beacon to help me focus on where I was.

Now if only I could add CodeRush Markers to Notepad and Word Smile

Published Jun 15 2011, 01:00 PM by Rory Becker - DevExpress
Bookmark and Share

Comments

 

Brad Schafbuch said:

Great idea to drop a marker on navigation commands, I had previously setup F12 (Go to Reference) to drop a marker and will be adding these too, thanks Rory!

June 15, 2011 9:16 AM
 

Jay Wren said:

ctrl-minus navigates previous locations in VS by default, I think same as alt-left

awesome usage of "after executing this command let VS handle it too."

June 15, 2011 10:07 AM
 

Rory Becker - DevExpress said:

@Brad: Indeed this should be useful in other navigational scenarios.

@Jay: It's all about 'embrace and extend' my friend.

Adding the icing to Visual Studio :)

June 15, 2011 10:15 AM
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.