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

25,044

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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.

Share:
25,044
Samuel
Author by

Samuel

Updated on January 17, 2020

Comments

  • Samuel
    Samuel over 4 years

    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
    Samuel almost 12 years
    This is exactly what I want! We CANNOT lives without Resharper!!! :D Thank you very much.
  • Jason Malinowski
    Jason Malinowski almost 12 years
    It's worth mentioning that VB does have this under Edit > Next/Previous method towards the end of list.
  • Samuel
    Samuel over 10 years
    +1 for the effort even I already have accept another answer. Thank you for your time. Without Resharper, this is a good solution.
  • Shawn Kovac
    Shawn Kovac about 10 years
    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!
  • Shawn Kovac
    Shawn Kovac about 10 years
    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!!
  • Mat Fergusson
    Mat Fergusson over 9 years
    This is absolutely the correct answer and as a bonus it doesn't require us to buy and configure resharper.
  • Eduardo Wada
    Eduardo Wada almost 9 years
    I tried ctrl + alt + down and it turned my screen upside down
  • truthseeker
    truthseeker over 8 years
    Not working in VS 2015. Pressing assigned shortcut does nothing.
  • Brain2000
    Brain2000 about 8 years
    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".
  • NightOwl888
    NightOwl888 over 7 years
    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#).
  • Himanshu Patel
    Himanshu Patel over 7 years
    @Eduardo-wada, that is because of you display driver keyboard short cut. You need to disable that.
  • IEnjoyEatingVegetables
    IEnjoyEatingVegetables over 6 years
    That is the shortcut for Format.SpaceDown see docs.microsoft.com/en-us/visualstudio/ide/…
  • Stas Boyarincev
    Stas Boyarincev over 5 years
    In Visual Studio 2017 this work and for c# code editor.
  • Paul
    Paul almost 5 years
    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!
  • IneffaWolf
    IneffaWolf about 3 years
    @IEnjoyEatingVegetables I don't know what that shortcut even does. Do you reckon it's okay to rebind it?
  • IEnjoyEatingVegetables
    IEnjoyEatingVegetables about 3 years
    @IneffaWolf I wouldn't