Is there a keyboard shortcut to move the cursor between methods in Visual Studio 2010?
Asked Answered
S

10

53

Is there any keyboard shortcut to move the cursor between methods in Visual Studio? Is there any plugins that can do the same job?

All the time when I program, I want to go at the end of the current method and if I could have a shortcut that can move the cursor at the beginning of the next method and then just have to type a couple of up arrow to be where I want would be fantastic.

Thank you.

Semipalmate answered 20/6, 2012 at 20:20 Comment(0)
B
26

Visual Studio doesn't have such a function, but JetBrains' ReSharper does. At least is the only one that I know of to offer this functionality.

For ReSharper the shortcuts are Alt-Up and Alt-Down, for previous/next member.

Brill answered 20/6, 2012 at 20:23 Comment(2)
This is exactly what I want! We CANNOT lives without Resharper!!! :D Thank you very much.Semipalmate
It's worth mentioning that VB does have this under Edit > Next/Previous method towards the end of list.Suffering
M
69

Note: For VS <2015, the following works only for the VB.NET code editor. In VS 2015+, apparently the C# code editor is also supported.

While there are no default keyboard bindings to jump between methods, you can set them up yourself:

Go to ToolsCustomize…, then Keyboard…, and do the following:

  1. Search for the commands by typing Method in the input line at the top.

  2. Locate the two commands Edit.NextMethod and Edit.PreviousMethod.

  3. For each of these, select the command first, then move the input focus to the input field Press shortcut keys, enter an unassigned key combination, and press the Assign button.

Options dialog where keyboard bindings can be set up and modified

(The screenshot above shows that I have previously assigned one of these commands to Ctrl+Shift+<.)

Markland answered 11/10, 2013 at 7:24 Comment(7)
+1 for the effort even I already have accept another answer. Thank you for your time. Without Resharper, this is a good solution.Semipalmate
it is not under "Tools, Customize" (in VS 2010 which i use). but the pic helped me find that it was really under "Tools, Options" instead. i was able to assign a shortcut key now, and it's great. Thanks!!Multiparous
This is absolutely the correct answer and as a bonus it doesn't require us to buy and configure resharper.Keffiyeh
Not working in VS 2015. Pressing assigned shortcut does nothing.Kaiserslautern
In order to make this work, don't forget to click the "Assign" button. Also, I would set it for "Text Editor" instead of "Global".Abstractionism
In Visual Studio 2017 this work and for c# code editor.Seymore
This definitely works, just did it on 2019. The key is setting it for Text Editor like @Abstractionism said, thank you, thank you, thank you!Viridis
T
31

Hi another (cheaper) alternative might be the CTRL+M+M to collapse/expand the current method to it's definition, allowing you to quickly navigate to the next. Also CTRL+M+O to collapse all members is useful, with CTRL+M+L to expand all again.

Tarrant answered 7/11, 2012 at 14:35 Comment(0)
B
26

Visual Studio doesn't have such a function, but JetBrains' ReSharper does. At least is the only one that I know of to offer this functionality.

For ReSharper the shortcuts are Alt-Up and Alt-Down, for previous/next member.

Brill answered 20/6, 2012 at 20:23 Comment(2)
This is exactly what I want! We CANNOT lives without Resharper!!! :D Thank you very much.Semipalmate
It's worth mentioning that VB does have this under Edit > Next/Previous method towards the end of list.Suffering
C
11

Try Ctrl + Alt + Up. This first takes you to the scope selector where you can select a class if applicable, then press Tab which takes you to the method selector where you can select a method from the selected scope.

Note I use In Visual Studio 2012, don't know if works in other versions.

Caddish answered 8/12, 2013 at 12:9 Comment(4)
i use VS 2010. (i cannot stand the colors in VS 2012. :(( ) And in VS 2010, this works j ust as described. Thanks for mentioning this!Multiparous
I tried ctrl + alt + down and it turned my screen upside downCross
@Eduardo-wada, that is because of you display driver keyboard short cut. You need to disable that.Folacin
Note that this is the shortcut for the Edit.NextMethod command (in my VS 2022) but it actually navigates not only between methods but also between fields, constructors and properties.Squatter
B
3

Jason Malinowski is right on his comment. It even says the shortcut keys are Ctrl+Down Arrow and Ctrl+Up Arrow. I used to use this all the time in VB6, but when I tried it lately using recent versions of visual studio, it didn't work; it would just scroll the edit window up or down one line.

When I went into Tools -> Options, select "Environment" on the left, and then the subcategory of "Keyboard", then type "Edit.ScrollLineDown" it said Ctrl+Down Arrow. When I removed this shortcut (and the one for ScrollLineUp), the next/previous method shortcuts then worked! I'm personally very happy about this.

Obviously, if you can find the right command, you can customize your keyboard shortcuts any way you please here.

Browder answered 19/2, 2013 at 17:34 Comment(2)
This works (in VS2015), but only if you also change the "Apply the following additional keyboaard mapping scheme" to Visual Basic 6 as well (even if you are using C#).His
I just tried this in Visual Studio 2017 - removed the shortcuts for Edit.ScrolLineDown (and up). Ctrl+Down Arrow and Ctrl+Up Arrow now move between methods IN C#!Browder
S
1

I know this is old, but looks like it was added since.

Try Alt+[ or Alt+]

Sepal answered 16/6, 2017 at 2:49 Comment(0)
C
0

In Visual Studio 2013 with the commercial Visual Assist expansion you can use ALT+M to open a list with all methods in the current file. Select one, hit ENTER and the cursor will jump to it.

Cheviot answered 14/9, 2017 at 12:11 Comment(0)
A
0

do not forget about the excellent, free DPack extension, which will add Alt+m shortcut which will open a list of all methods in the current class. You can type a search string to filter, and what is also great is if you tab down and enter on a method, and then later do Alt+m again, if you tab into the window you will be on the last method you selected. DPack also has many more features, like bookmarks, but I do find that you have to setup the hotkeys, or more exactly, re-assign hotkeys from other functions to DPack: https://marketplace.visualstudio.com/items?itemName=SergeyM.DPack-16348

Alsacelorraine answered 2/7, 2019 at 7:44 Comment(0)
O
0

Its Ctrl + } - by placing the cursot to end of line - using studio 2015

Same will also bring the cursor back to bottom.

so place the cursor at end of function and press Ctrl + }

Organography answered 17/1, 2020 at 9:46 Comment(0)
D
-4

In Visual Studio 2015:

Alt + Up or Alt + Down

December answered 17/10, 2017 at 8:21 Comment(3)
That is the shortcut for Format.SpaceDown see learn.microsoft.com/en-us/visualstudio/ide/…Fetter
@Fetter I don't know what that shortcut even does. Do you reckon it's okay to rebind it?Triley
@IneffaWolf I wouldn'tFetter

© 2022 - 2024 — McMap. All rights reserved.