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

vi bindings #92

Closed
wants to merge 1 commit into from
Closed

vi bindings #92

wants to merge 1 commit into from

Conversation

saysjonathan
Copy link

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.

example.c was also updated to introduce a new flag that enables vi bindings.

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.
@dumblob
Copy link

dumblob commented Oct 3, 2015

+1 the patch looks fine

@eggsyntax
Copy link

Any blocks to merging this? It'd be reeeaaaaaalllly nice to have.

@zorbash zorbash mentioned this pull request Feb 3, 2016
@dumblob
Copy link

dumblob commented Jun 25, 2016

@saysjonathan do you plan to resolve the merge conflicts any time soon?

@lethosor
Copy link

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.

@dumblob
Copy link

dumblob commented Apr 14, 2017

@lethosor the algorithm seems a bit better, but it won't be accepted as it completely changes the library - namely it seems to switch from C to C++, which is a great pity. @wingeng, do you have any plans to make it compatible with the ideas linenoise was built around?

@lethosor
Copy link

Sorry, that branch changed a lot since I mentioned it - I was referring to just the first 3 commits in that PR.

@wingeng
Copy link

wingeng commented Apr 14, 2017

@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.

@antirez
Copy link
Owner

antirez commented Apr 14, 2017

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?

@dumblob
Copy link

dumblob commented Apr 15, 2017

...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 set -o vi mode is powerful and very handy.

Do you @antirez also use the full power of set -o vi in zsh or rather really just "immediate moving across the line"? Could you also please elaborate what exactly you mean with the question "Any hint?"?

@michael-776
Copy link

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.

@Sonophoto
Copy link

@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...

@michael-776
Copy link

michael-776 commented Jul 25, 2017

@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 :)

@saysjonathan saysjonathan closed this by deleting the head repository Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants