microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.48k stars 29.37k forks source link

Move between symbols in current file with keyboard shortcuts #46153

Closed garyking closed 4 years ago

garyking commented 6 years ago

Please add the ability to move between symbols in the current file with keyboard shortcuts.

Symbols are already detected in many languages. It would be useful to have a keyboard shortcut, such as Ctrl-Down to select the next symbol in the file. This would be similar to Move by Symbols for Sublime Text.

Here's how it works in Sublime, using Ctrl-Down/Up:

move by symbol

vscodebot[bot] commented 6 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

Tyriar commented 6 years ago

@dbaeumer not sure who this request should go to, please forward it on if you're not the right person.

dbaeumer commented 6 years ago

Assigning to @jrieken since this might require language API unless we reuse the document symbol result.

jrieken commented 5 years ago

We could use outline information for this and see how far we get. Later, we can always add a real provider for this

jrieken commented 4 years ago

I have removed/unhooked the current approach because we weren't happy with it

jasonwilliams commented 3 years ago

Hey @jrieken is this still a possibility? Or was it achieved in another way?

jasonwilliams commented 3 years ago

I've created a new feature request here: https://github.com/microsoft/vscode/issues/126927 which references this old issue

jasonwilliams commented 3 years ago

If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

I don’t agree with the closing of this.

VSCode's code navigation would really help with being able to move between symbols. Other IDE's have this built in, Sublime, Vim, IntelliJ etc. Keyboard users need to do some tough manoeuvring to get to a function below or a class (either GoToLine which is a few steps, or opening up symbols table). Having the ability to cycle through all symbols in a file would really help.

Risks

The main risk is adding bloat, which I understand. However in this case we're not adding a new feature. You can already cycle through symbols using Cmd+Shift+O (MacOS), this feature request is just allowing users to have this as a keybinding.

Implementations

https://marketplace.visualstudio.com/items?itemName=mishkinf.goto-next-previous-member exists although its no longer maintained. There is the argument it could be an extension but a feature this low level I'd expect to be baked in (as it is in other IDEs). Also there shouldn't be much extra work here, as you can already do this in the UI (as mentioned above).

I've set the above to ctrl+shift+{up, down} (as these seems to be free)

LeonardoRick commented 1 year ago

Is this closed? This feature sounds crucial to me and seems to be really something missing on vscode

mertekren commented 1 year ago

this is a must feature.

karansapolia commented 1 year ago

I wanted to jump to the beginning of the function I was in today, did not find that, so looked for this feature today in VS Code settings, then on Stackoverflow and then just settled with using goto symbol UI. But please allow us to use this as a keybinding like @jasonwilliams suggested.

Would be amazing if we could setup keybindings to goto next symbol above and below :)

kyunussov commented 1 year ago

Yes, the extension mentioned - Go to Next/Previous Member - provides this functionality nicely, but seems this should be built-in. I just wasted 40 min trying to find it in VS Code, ended up getting the extension.

stephan-noel commented 7 months ago

I'd also like to see this, it's much quicker than opening a dropdown and then having to scroll through the many symbols there. Seems like it was implemented before but then was only removed as a temporary workaround to a conflicting shortcut in https://github.com/microsoft/vscode/issues/84783#issuecomment-553834951.

ctrl+shift+{up, down} mentioned by @jasonwilliams seems to still be available and the issue https://github.com/microsoft/vscode/issues/126927 which he opened was closed as a duplicate. Can we at least re-open this issue since technically it's removal was supposed to be temporary?

stephan-noel commented 7 months ago

Just wanted to add for anyone coming here, I've been using Ctrl (or Cmd) + Shift + . in the meantime.

It opens an ordered inline nested accordion to the side whose default expansion is automatically synced with your cursor's current position:

image

This has been a much better experience for me than the top search bar which blocks your view and which is completely flat. Hope this helps someone.

Credit to the youtube video I found this in.