Coder Social home page Coder Social logo

Vi mode seems incomplete about reedline HOT 19 OPEN

evccyr avatar evccyr commented on June 2, 2024 2
Vi mode seems incomplete

from reedline.

Comments (19)

fdncred avatar fdncred commented on June 2, 2024 3

keyboard chords are not currently supported in reedline, although we'd love to support them.

from reedline.

crides avatar crides commented on June 2, 2024 3

The vi editing modes are the last thing for me to more extensively try out nushell, otherwise the other parts feel very nice to me. Basically I would love to see the vi editing mode to be on par with zsh. Some of the problems/missing pieces have been listed above, but I'll add my observations:

  • B is completely wrong. abc def ghi with the cursor at the end, pressing B gets to the g and then a, completely skipping the d (meanwhile W seems to be correct)
  • $ goes beyond the last character, leading to e.g. $x doesn't delete the last character in the line
  • count on operations is missing e.g. 3f,
  • f/F/t/T seems to be implemented in 0.65.0, but doesn't work on any chars that can otherwise have other meaning, e.g. numbers, ^, $

I would love to make these changes myself or at least dig into what the problems are, but unfortunately I won't have much free time for quite a while 😢

from reedline.

sholderbach avatar sholderbach commented on June 2, 2024 1

Ctrl bindings should be possible

from reedline.

fdncred avatar fdncred commented on June 2, 2024

mabye these keybindings are common knowledge to most people but for me, it would be good to have a description of what you're requesting other than just having keybindings by name. what do you want them to do? Also, have you tried defining them yourself? keybindings are pretty powerful in nushell these days. https://www.nushell.sh/book/line_editor.html#default-keybindings

from reedline.

matiu3 avatar matiu3 commented on June 2, 2024
  • I'd like to see r replace current character.
  • I often use x (cut char at cursor) p (paste) to move a character one space forwards, but p seems to just paste random stuff, not the charcter I just xd.
  • I use C (capital C) for "change until end of line"
  • f <some_char> - move forward to <some_char>
  • F same as above but move backwards
  • ctrl+d - exit the shell

All these were working until I updated today, now I feel like I'm disabled without my shortcuts :p

Also thank you very much for this great product.

from reedline.

evccyr avatar evccyr commented on June 2, 2024

mabye these keybindings are common knowledge to most people but for me, it would be good to have a description of what you're requesting other than just having keybindings by name. what do you want them to do? Also, have you tried defining them yourself? keybindings are pretty powerful in nushell these days. https://www.nushell.sh/book/line_editor.html#default-keybindings

u don't use vim?

from reedline.

evccyr avatar evccyr commented on June 2, 2024
  • normal mode

    • shift+s clear entire line and switch to insert mode
    • shift+i prepend to line(switch to insert mode). It's similar to shift+a but in the start of the line.
  • insert mode

    • ctrl+w move right one word similar to ctrl+f except it "moves to the right, entire line"
  • search mode

    • Esc exit search mode

I haven't included any of @matiu3 's suggestions do avoid duplication but they are just as important.

Also, I'm not sure if it's possible to implement Shift+Backspace but it'd be nice too.

from reedline.

matiu3 avatar matiu3 commented on June 2, 2024

I think, as things are, one would need to manually add all these to reedline and there's a lot of work there.

Perhaps an easier solution would be to make it possible to swap out reedline with readline or zle, both of which already have the keybindings programmed ?

Or is it possible for us users to manually program these into the config file ? I get the feeling it's not that fine grained. If it is, please get us started and we can collaborate in filling it in.

from reedline.

evccyr avatar evccyr commented on June 2, 2024

Or is it possible for us users to manually program these into the config file ? I get the feeling it's not that fine grained. If it is, please get us started and we can collaborate in filling it in.

Can you please tell me how to use multiple edits?

    {
      name: clear_line
      modifier: shift
      keycode: char_c
      mode: vi_normal
      event: {
        edit: cleartolineend
      }
    }

In the above keybinding I'm in normal mode and then I clear to the end of the line, now I want to switch to insert mode. How do I do that? Most of the bindings I need can be made if you just let me know how to switch between normal & insert modes while configuring a binding.

Or maybe paste the configuration for Shift+a which is already present and works fine although I couldn't find it anywhere in the source code of this repo.

from reedline.

fdncred avatar fdncred commented on June 2, 2024

u don't use vim?

never.

... how to switch between ...

Have you tried adding multiple edit events like the documentation shows? https://www.nushell.sh/book/line_editor.html#keybindings. Maybe adding an insertchar or insertstring will switch the mode. I'm not sure. @elferherrera is the keybinding guru, maybe he knows.

if you do keybindings list you can see what events/etc are available in keybindings.

most all of the vi stuff is defined here https://github.com/nushell/reedline/tree/main/src/edit_mode/vi

from reedline.

evccyr avatar evccyr commented on June 2, 2024

u don't use vim?

never.

... how to switch between ...

Have you tried adding multiple edit events like the documentation shows? https://www.nushell.sh/book/line_editor.html#keybindings. Maybe adding an insertchar or insertstring will switch the mode. I'm not sure. @elferherrera is the keybinding guru, maybe he knows.

if you do keybindings list you can see what events/etc are available in keybindings.

I've gone through the docs and also adding multiple edit statements including insert, insertstring... but there's no way I'm dropped to insert mode. I also tried sending event i(switch to insert mode) but helpless.

from reedline.

evccyr avatar evccyr commented on June 2, 2024

Let's work on a single binding first as an example:

    {
      name: prepend
      modifier: shift
      keycode: char_i
      mode: vi_normal # Options: emacs vi_normal vi_insert
      event:[
          { edit: MoveToLineStart }
          { edit: InsertString,
            value: ""  }
        ]
      }
    }

Right now this only half works. It takes me to the start of the line but doesn't drop me into insert mode, not even keycode: insert. Also the examples mentioned in the docs are mostly for emacs so don't help much.

from reedline.

fdncred avatar fdncred commented on June 2, 2024

@sholderbach also understands the vi configuation too. He may be able to help also.

from reedline.

sholderbach avatar sholderbach commented on June 2, 2024

The command parser for the typical vi sequences is hand built at the moment and not amenable to configurable keybindings yet. Only ctrl sequences are handled by the configurable keyparser used with emacs style mode.
There is definitely work to be done on vi mode to get more of the commands and movements to parity. I don't know if parity in configurable keybindings for vi (a la "nmremap whatever") is a reasonable goal at the moment.

from reedline.

evccyr avatar evccyr commented on June 2, 2024

Hey, @sholderbach I was just taking a look at the reedline's source code. I'm still a rust beginner but looking at the source code I wondered why some of the bindings are missing or why they haven't been implemented and maybe there's a way to quickly implement them.
As an example I thought the since the behavior of shift+i is similar to that of shift+a, then a little copy pasting got me to this:
https://github.com/zim0369/reedline/commit/5621bf829d969e38a72925aa1216c6bcb127a3b5
Would this commit successfully implement the vim's shift+i behavior?

from reedline.

sholderbach avatar sholderbach commented on June 2, 2024

I think there is one extra step, to make sure it switches into insert mode but I am happy to walk you through a PR. Thanks for giving it a shot!

from reedline.

evccyr avatar evccyr commented on June 2, 2024

insert mode
ctrl+w move right one word similar to ctrl+f except it "moves to the right, entire line"

Hey @fdncred , Is it possible to make this binding in config.nu without having to make any changes to "reedline"?

from reedline.

evccyr avatar evccyr commented on June 2, 2024

I will close this issue once 'x', 'w' & 's' are fixed and 'e', '?', 'S', 'r', 'R', 'y', 'around' & 'inside' are implemented.

from reedline.

jcjolley avatar jcjolley commented on June 2, 2024

Many vim users (myself included) rebind <ESC> or Ctrl+[ to a chord like "jk" or "jj".
How difficult would it be to modify the keybindings keycode property to accept a list of keybinds?

from reedline.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.