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

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
9 participants
@saysjonathan

saysjonathan commented May 3, 2015

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.

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

This comment has been minimized.

Show comment
Hide comment
@dumblob

dumblob Oct 3, 2015

+1 the patch looks fine

dumblob commented Oct 3, 2015

+1 the patch looks fine

@eggsyntax

This comment has been minimized.

Show comment
Hide comment
@eggsyntax

eggsyntax Jan 22, 2016

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

eggsyntax commented Jan 22, 2016

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

@zorbash zorbash referenced this pull request Feb 3, 2016

Open

vi mode? #3

@dumblob

This comment has been minimized.

Show comment
Hide comment
@dumblob

dumblob Jun 25, 2016

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

dumblob commented Jun 25, 2016

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

@lethosor

This comment has been minimized.

Show comment
Hide comment
@lethosor

lethosor Jun 28, 2016

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.

lethosor commented Jun 28, 2016

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.

@gwenn gwenn referenced this pull request Nov 5, 2016

Closed

vi mode #94

@f18m

f18m approved these changes Apr 14, 2017

@dumblob

This comment has been minimized.

Show comment
Hide comment
@dumblob

dumblob 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?

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

This comment has been minimized.

Show comment
Hide comment
@lethosor

lethosor Apr 14, 2017

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

lethosor commented Apr 14, 2017

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

@wingeng

This comment has been minimized.

Show comment
Hide comment
@wingeng

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

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

This comment has been minimized.

Show comment
Hide comment
@antirez

antirez Apr 14, 2017

Owner

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?

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

This comment has been minimized.

Show comment
Hide comment
@dumblob

dumblob 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?"?

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

This comment has been minimized.

Show comment
Hide comment
@michael-776

michael-776 Jul 22, 2017

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 commented Jul 22, 2017

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

This comment has been minimized.

Show comment
Hide comment
@Sonophoto

Sonophoto Jul 25, 2017

@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 commented Jul 25, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@michael-776

michael-776 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 :)

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

@rain-1 rain-1 referenced this pull request May 15, 2018

Open

PR #92 #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment