reedline icon indicating copy to clipboard operation
reedline copied to clipboard

Default keybind for "newline"

Open NotTheDr01ds opened this issue 1 year ago • 1 comments

Nushell pipelines are best split over multiple lines, and the nufmt specification recommends "wall of pipes" formatting. E.g.:

ls
| where size > 0kb
| insert name_length {$in.name | str length}

However, that's extremely tedious to create "out of the box" with Nushell/Reedline at the moment, since a Enter only creates a newline in this case if there's a trailing pipe character on the existing line. E.g.:

  • ls | + Enter will create a newline which can be followed by the next expression, but
  • ls + Enter executes the command (as it should - I'm not advocating for that to change ;-).

In order to create the "wall of pipes", you have to start with the first form ls |, hit Enter , then continue your | pipeline, and then (if you're pedantic) remove the trailing pipe from the previous line. You could also do something like start the pipeline with a ( open-paran to keep Enter from executing the pipeline until complete.

While it's relatively easy for a user to create a keybinding in their config to map Alt+Enter (assuming macOS ?), given the importance of newline in Nushell CLI-usage, I'd recommend this be a built-in keybinding.

Note: This is built-in to the Fish shell.

NotTheDr01ds avatar May 20 '24 13:05 NotTheDr01ds

Ya, I've always thought the pipes belong on the right side for the same reasons. I have this in my keybindings because the problem with alt-enter is that it's not free in all terminals.

  {
    name: insert_newline
    modifier: alt
    keycode: char_i
    mode: [emacs vi_normal vi_insert]
    event: { edit: insertnewline }
  }
  {
    name: insert_newline
    modifier: alt
    keycode: enter
    mode: [emacs vi_normal vi_insert]
    event: { edit: insertnewline }
  }

But I wouldn't have a problem with adding these to the default_config.nu and in the rust code.

fdncred avatar May 20 '24 14:05 fdncred

Closed by #854

sholderbach avatar Nov 21 '24 09:11 sholderbach