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

Default keybind for "newline" #792

Closed
NotTheDr01ds opened this issue May 20, 2024 · 2 comments
Closed

Default keybind for "newline" #792

NotTheDr01ds opened this issue May 20, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@NotTheDr01ds
Copy link
Contributor

NotTheDr01ds commented May 20, 2024

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 NotTheDr01ds added the enhancement New feature or request label May 20, 2024
@fdncred
Copy link
Collaborator

fdncred commented May 20, 2024

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.

@sholderbach
Copy link
Member

Closed by #854

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants