Open antifuchs opened 12 months ago
Agreed, that having that syntax aware behavior could make things more delightful (e.g. around the Hinter
autosuggestions as well).
As the sane tokenization is syntax dependent, the question would be how we share that responsibility with the shell/application around reedline
. Nushell would have a slightly different tokenization compared to a POSIX shell or for example a lisp.
Some general text objects we could provide like the balanced expressions/vim text objects. But there could be things that are language specific. (Flags would be pretty common accross shells but not found in a lot of other languages)
I agree that this likely won't ever be fully precise like a language grammar could be: I think having something that can precisely jump over lexer tokens, that would be great already!
Currently, reedline ships key bindings to go to the next/prev word (in emacs mode, that's M-f and M-b). Those are great, but it would be great to complement these with a set of navigation keys that go to the next/prev full "syntax element".
An example to illustrate what I mean: say you're trying to work with a very long command line, and you need to replace a very long element in that command line:
Assume you'd like to remove that
--short-names
and replace it with--full-paths
. To get there, you can jump to the beginning of the line, then delete the next word twice, or from the end of the line, hit "go back a word" a bunch of times, until you're between the beginning of the string and the end of--short-names
, then hit the backwards-delete-word command 6 times (2 words and two hyphens - props for not doing weird things when encountering those, by the way!) .As a much shorter & more precise way to edit that line, it would be great if there was a way to delete/jump over the entirety of that quoted string (or the
--short-names
argument), instead of going character-by-character or word-by-word (which stops so many times).With this feature, editing the command-line would be the following:
--full-paths
. Or,This feels much easier and requires much less thought & key-hitting!
References
(parenthesized lists)
or"entire strings"
: https://www.gnu.org/software/emacs/manual/html_node/emacs/Expressions.html)
when you're at an opening(
paren) with the%
key. I believe[(
and similar commands do a similar thing, too.zle select-a-shell-word
primitive; if reedline exposed a function to know where the expression starts and ends somehow, I'd already be happy - then I could write all the reedline scripts to do what I need, I think (: