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

Ctrl-U and other default bindings in the REPL are a bit counter-intuitive #20145

Closed
tobia opened this issue Apr 19, 2018 · 1 comment
Closed
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem.

Comments

@tobia
Copy link

tobia commented Apr 19, 2018

  • Version: v10.0.0-nightly20180419bbdb4af0bd
  • Platform: Linux 4.10.0-42-generic 46~16.04.1-Ubuntu SMP Mon Dec 4 15:57:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I'm not sure what library (or custom code) Node uses to handle line editing in the REPL, but being accustomed to Bash and GNU Readline (as most people probably are nowadays) some of the default bindings are a bit counter-intuitive.

The most egregious one being Ctrl-U, which in Node kills the whole line. In Bash and other Readline-based CLI, Ctrl-U only kills the part of the line before the cursor, as a counterpart to Ctrl-K. I think this is a bad default binding, because a lot of people will have Ctrl-U in their muscle memory and don't expect it to kill the whole line. The problem is compounded by the lack of Ctrl-Y (see below) and Ctrl-X Ctrl-U, either of which would allow you to undo the change.

Another different one is Ctrl-W, which in Node kills the last /\b/-separated word, instead of the last /\s/-separated word as it does in Bash / Readline. Also Ctrl-Y does not seem to yank the last killed string, which makes it impossible to move text around using the keyboard.

I was just wondering if any thought had been given to following the Bash / Readline default bindings, because that's what most users are presumably used to. (I'm not saying Bash or Readline are better or more "right" than the alternatives, just that it's the most used shell in the most used OS for Node development.)

@bnoordhuis bnoordhuis added readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem. help wanted Issues that need assistance from volunteers or PRs that need help to proceed. labels Apr 19, 2018
@bnoordhuis
Copy link
Member

bnoordhuis commented Apr 19, 2018

Pull requests welcome, I'd say.

Ctrl-U only kills the part of the line before the cursor

I think that's an acceptable change.

Also Ctrl-Y does not seem to yank the last killed string

readline doesn't have a concept of yank buffers. Some discussion is probably necessary on how to add that. It should gel well with the public API.

Another different one is Ctrl-W, which in Node kills the last /\b/-separated word, instead of the last /\s/-separated word as it does in Bash / Readline.

FWIW, that's deliberate because you often type obj.wrong^Wright. Vim works the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issues that need assistance from volunteers or PRs that need help to proceed. readline Issues and PRs related to the built-in readline module. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants