-
Notifications
You must be signed in to change notification settings - Fork 666
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
vi bindings #92
vi bindings #92
Conversation
This change introduces vi bindings while maintaining the original API. A shim function was created that enables vi mode then passes off to the normal API, linenoise(). A few additional functions were created to support common key actions, including: * linenoiseEditMovePrevWord * linenoiseEditMoveNextWord * linenoiseEditDeleteNextWord The bindings are not meant to be comprehensive but to provide basic functionality by implementing the most common actions.
+1 the patch looks fine |
Any blocks to merging this? It'd be reeeaaaaaalllly nice to have. |
@saysjonathan do you plan to resolve the merge conflicts any time soon? |
FWIW, I think the algorithm in #64 is closer to vim's behavior (and readline's, for that matter). Few implementations I've seen consider only spaces to be word boundaries. |
Sorry, that branch changed a lot since I mentioned it - I was referring to just the first 3 commits in that PR. |
@dumblob Wow, been a long time since I saw this code. Sorry about the massive changes to the code-base, the style was driving me nuts. I don't have much time now-a-days to work on this... but I may in a couple of weeks as some current work projects may allow me to revisit this. BTW, did you just want the fixes to the word boundaries navigation? That was done prior to the C++ switch over. |
The code looks well written and does not change radically the linenoise code base in order to add such a support, however the question is if it's a fit for a small library to add such a mode. The code complexity will get a bit bigger but the concept of ANSI-C single file remains. Not sure... Btw I'm a vim user myself and I use the vim mode in zsh sometimes, but vim modes in the end tend to be very limited, naturally, so it is never a great experience. But still I use it in order to immediately move across the line. Any hint? |
Well, it is not the best experience (compared to (n)vim, whose feature set can't be even reached because of the shell semantics), but on my side it saves me a huge amount of time (and saves me from swearing "how slow and error-prone it is to work with pure POSIX shell" and thus makes me way more comfortable) when it comes to a command line work. I actually use in shell (mostly Bash) nearly all the commands from the original vi, so I can say the Do you @antirez also use the full power of |
Having a vi mode is a serious accessibility issue for people for whom repeated keyboard chording causes physical pain (e.g. http://ergoemacs.org/emacs/emacs_kb_shortcuts_pain.html). I use vi emulation in Emacs for this reason. So I hope you will please merge the vi bindings. |
@michael-776 You know you can fork the linenoise repo and mod it to your hearts content? Right? I use a customized linenoise with changes specific to my needs/tastes: https://github.com/Sonophoto/linenoise/commits/master/linenoise.c I haven't used the "official" linenoise in years... |
@Sonophoto RE: "you know you can fork the linenoise repo and mod it to your hearts content?" I do know, yes, thanks for the suggestion. But I'm not a C programmer, and lots of other people aren't either. I was just throwing my two cents in on the usefulness of having a vi mode. Well.. and making a plea for help, I admit :) |
This change introduces vi bindings while maintaining the original API. A shim function was created that enables vi mode then passes off to the normal API, linenoise().
A few additional functions were created to support common key actions, including:
The bindings are not meant to be comprehensive but to provide basic functionality by implementing the most common actions.
example.c
was also updated to introduce a new flag that enables vi bindings.