Move up and down scopes / expressions #24440
thomasheartman
started this conversation in
Ideas From Emacs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Emacs's
smartparens
package has commands that move you up/down/to next/to previous expression (sp-*-sexp
functions, such assp-backward-up-sexp
,sp-previous-sexp
, etc). They're quite similar to Emacs's nativedown-list
,backward-up-list
, etc.From the doc string for
sp-backward-up-sexp
:From the doc string for
down-list
:In effect, this lets you move to an enclosing scope, down a scope, to next item etc. I think Zed has a chance to do something very similar through tree-sitter. Zed already exposes
SelectLargerSyntaxNode
as an action, but it doesn't expose a dedicated movement function.I'm not super familiar with tree-sitter, but I imagine Zed could introduce something like "Next/PreviousSyntaxNodeSameLevel", "LargerSyntaxNode", "SmallerSyntaxNode" to achieve very similar results. As a bonus, this also makes it very easy to delete syntax nodes like this and could be very useful in vim mode (long time evil mode user 🙋🏼 ) as motions/text objects (delete around larger syntax node, etc)
While this kind of movement excels in lisps, it's also really useful for navigating JSON and general C-like languages.
Beta Was this translation helpful? Give feedback.
All reactions