Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

keyboard shortcut to move from one code block to another in VS2008

In Visual Studio 2008 is there a shortcut to move from one block of code to an another block of code directly? Like from one function to say: the beginning of next function.
Currently all I can do is press-press arrow keys.

Edit: I am aware of the Ctrl+] to jump between matching braces but that does not relieve me from multiple up/down presses initially. Also the "Edit.NextMethod" does not work as it is always disabled unless you are editing VB Code (It does not appear to work their either).

like image 762
Ujjwal Singh Avatar asked Mar 16 '12 20:03

Ujjwal Singh


3 Answers

If you place your cursor to the left of the opening {, then Ctrl+} will move you to the end of this method/block/operator

like image 62
Flot2011 Avatar answered Sep 17 '22 23:09

Flot2011


Macros is the Solution: Shipped with VS2008 are sample macros that contain:
Sample.VSEditor.BeginningOfFunction - to move to the beginning of a function. This can be modified to get it to move to the End of the function instead by changing: CodeElement.GetBeginningPoint to GetEndPoint. Next an another user-defined macro: NextMethod() first navigates to the end of current function then finds the next function and finally moves to the beginning of this next function.

Get the Macro: http://social.msdn.microsoft.com/Forums/en/csharpide/thread/8c5a2fd2-df25-4196-b211-5da3086f4f3d

like image 35
Ujjwal Singh Avatar answered Sep 18 '22 23:09

Ujjwal Singh


In VB.NET (VS 2010) I wanted to reinstate the old feature of the VB6 editor to navigate to the next and previous methods in a class by hitting the Ctrl-DownArrow and Ctrl-UpArrow.

This was straightforward taking the following steps:

  • Go to Tools / Options then Environment / Keyboard.
  • In the "Show commands containing:" field, type "Edit.NextMethod". This command should then appear in the listbox. Click on it to select it.
  • Click on "Press shortcut keys:" to get focus there. Press Ctrl+Up Arrow keys. Check that this key combination now appears in the textbox.
  • Look in the textbox below "Shortcut currently used by:". Check that the shortcut currently used by this key combination is not one you want! [unlikely, otherwise you would not be trying to remap the keys]
  • Click on the "Assign" button
  • Then click on "OK"

You can do the same with Edit.NextMethod and Ctrl+Down Arrow.

like image 26
finch Avatar answered Sep 16 '22 23:09

finch