52

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.

Samuel
  • 12,073
  • 5
  • 49
  • 71

10 Answers10

68

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+<.)

stakx - no longer contributing
  • 83,039
  • 20
  • 168
  • 268
  • 8
    +1 for the effort even I already have accept another answer. Thank you for your time. Without Resharper, this is a good solution. – Samuel Dec 11 '13 at 21:02
  • 3
    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!! – Shawn Kovac Feb 28 '14 at 16:40
  • 5
    This is absolutely the correct answer and as a bonus it doesn't require us to buy and configure resharper. – Mat Fergusson Nov 18 '14 at 12:41
  • Not working in VS 2015. Pressing assigned shortcut does nothing. – truthseeker Dec 17 '15 at 09:27
  • 5
    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". – Brain2000 Apr 12 '16 at 12:22
  • In Visual Studio 2017 this work and for c# code editor. – Stas Boyarincev Nov 27 '18 at 09:37
  • This definitely works, just did it on 2019. The key is setting it for Text Editor like @Brain2000 said, thank you, thank you, thank you! – Paul Jul 17 '19 at 03:28
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.

user369142
  • 2,575
  • 1
  • 21
  • 9
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.

Marcel N.
  • 13,726
  • 5
  • 47
  • 72
10

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.

Beginner
  • 223
  • 2
  • 10
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.

Marian Nasry
  • 821
  • 9
  • 22
Steve
  • 531
  • 5
  • 16
  • 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#). – NightOwl888 Oct 14 '16 at 09:32
  • 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#! – Steve Apr 06 '23 at 20:53
1

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

Try Alt+[ or Alt+]

Albert
  • 1,062
  • 2
  • 13
  • 20
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.

VisorZ
  • 526
  • 1
  • 5
  • 15
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

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 + }

Anurag.Desai
  • 103
  • 1
  • 15
-4

In Visual Studio 2015:

Alt + Up or Alt + Down

Mohsen Afshin
  • 13,273
  • 10
  • 65
  • 90