Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyboard shortcut to jump to next/previous line with the same indentation level #22133

Closed
hprodh opened this issue May 29, 2024 · 6 comments
Closed

Comments

@hprodh
Copy link

hprodh commented May 29, 2024

I have a feature/enhancement request for the editor.
I would like to navigate faster within code using the keyboard (typically from class to class or function to function, etc...).
One perfect feature would be to have a keyboard shortcut to make the cursor jump to the next or previous line having the same indentation level as the current one. So that the shortcut would allow to easily jump indented blocks.
By the way, another shortcut to go the previous/next line having one less indentation level would be very nice additionally.

@dalthviz
Copy link
Member

Hi @hprodh thank you for the feedback! Maybe something that could be useful for you then is the symbol switcher? With it, you can jump between definitions (functions, classes, methods, etc):

symbol_switcher

To show the symbol switcher you can use the Ctrl +Alt + P shortcut.

Let us know if the info above helps!

@dalthviz dalthviz self-assigned this Nov 26, 2024
@hprodh
Copy link
Author

hprodh commented Nov 27, 2024

Hi @dalthviz,
I just tried this functionality, this looks very nice indeed, usable from keyboard only !

Yet I find one problem with the use of the symbol finder : when opening it with Ctrl+Alt+P, the editor cursor goes to the first symbol. This throws back to the beginning of the file.
It would be very practical if it could open with the directly previous symbol selected, (and possibly should not move the cursor at opening).

@dalthviz
Copy link
Member

It would be very practical if it could open with the directly previous symbol selected

Thank you @hprodh for the extra feedback! I would say that makes sense to me 👍 Also, thinking about not changing the line where you are, I remembered that you can also activate a selector for classes/functions by checking Source > Show selector for classes and functions:

symbol_selector

Anyhow, in general, what do you think about these ideas @spyder-ide/core-developers (shortcuts to navigate the next/previous symbol and improvements to the symbol finder/switcher) ?

@hprodh
Copy link
Author

hprodh commented Nov 29, 2024

Yes, this selector is very close to what the symbol switcher is, yet they each have a drawback for "fast-keyboard-use-only" :

  • symbol switcher sends the cursor to the first symbol of the file at opening.
  • selector requires the usage of the mouse to open it (also, it takes a bit of space on screen).

I think it is better to fix the opening behavior of the symbol switcher. This functionality could then serve both as a contextual outline explorer and fast navigator, without having to change the default spyder configuration, just with the keyboard shortcut.

Additionally, a simple "bookmark" comment, if recognized as a symbol, would maybe close the issue #910.

@dalthviz
Copy link
Member

Thank you for giving the selector a try @hprodh !

Additionally, a simple "bookmark" comment, if recognized as a symbol, would maybe close the issue #910.

Just in case, there is already a mark/comment you can use to go to a specific place in your code. To use that functionality you just need to write # --- <some text> So for example, inside a class, if you want to mark a "section" where public methods are defined you can do something like # ---- Public API. After doing that you should see something like:

image

Those mark comments work for the symbol finder and also for the Outline pane

@hprodh
Copy link
Author

hprodh commented Dec 2, 2024

I have opened the new issue #23138. I am closing this one.

@hprodh hprodh closed this as completed Dec 2, 2024
@dalthviz dalthviz removed this from the wishlist milestone Dec 2, 2024
@dalthviz dalthviz removed their assignment Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants