Vi mode in Nix repl

Hey, is there any way to get vi mode in the Nix repl, please?

2 Likes

There is a tool called rlwrap that offers a vi-mode according to this question, though I can’t find any docs on that.
That might be an option. Nix repl does not support vi mode natively.

1 Like

Thank you for the tip. rlwrap sounds like too much trouble. I won’t bother. I do wonder, however… does nix repl use GNU readline?

Emacs has a vi mode. Emacs has a nix repl mode. Use emacs!

5 Likes

Seems like it doesn’t by default but can be compiled with Readline support so that it honors .inputrc?

2 Likes

This is one for the books.

Oh wow that’s an amazing solution, I had no idea that was possible. I’ll certainly try that out sometime!

Emacs is always the answer (regardless of the question)!

1 Like

I got all excited by this but it looks like it’s pretty vestigal, there is that ifdef but configure hardcodes editline. Which is not the more capable libedit from BSD, but a very minimal one with entirely hardcoded keys.

I also tried rlwrap but the catch is that it disables tab completion, since naturally rlwrap has no idea about nix. The commit that adds readline is from 2018, and mentions it doesn’t support completion and its trivial anyway. configure has libeditline hardcoded, so having a civilized REPL experience would amount to updating both configure and repl.cc, basically implementing from scratch. It’s not complicated though.

But, the bigger issue is that the standard line editing libraries in both GPL and BSD have existed for decades, yet nix chose to not use them, which implies it’s on purpose. So any work done to support a better REPL experience might just be rejected, without first finding out why it is the way it is.

1 Like

You can open a feature “request”, explain your reasoning and research, and indicate that you’re willing to implement, you just want to know whether it has any chance of being approved first.
It might take a while to get a response, but if you get a go, that’s at least a start.

The original reason for not including more complex libraries might have to do with binary size or other technical concerns that are not current anymore, Nix is almost 20 years old after all.

1 Like