问题
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).
回答1:
If you place your cursor to the left of the opening {
, then Ctrl
+}
will move you to the end of this method/block/operator
回答2:
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
回答3:
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.
回答4:
Ctrl+Up and Ctrl+Down will jump to previous/next function.
来源:https://stackoverflow.com/questions/9743888/keyboard-shortcut-to-move-from-one-code-block-to-another-in-vs2008