I comes from Python background and just begin to use scala.
In python shell, when I type in a command and find a typo in it, I usually use ctrl c to generate a keyboard Interrupt exception so that I can directly type the next statement. The previous statement won't be executed, and I'm still in Python shell.
But in Scala REPL, when I enter ctrl c, I'll immediately quit the Scala REP, which is annoying to me.
Is there anyway to make REPL works like python shell?
Scala version I'm using is 2.11.7. I'm using Mac.
Exit(0); import 'dart:io'; exit(0);
We can start Scala REPL by typing scala command in console/terminal.
You could try Ammonite-REPL by Li Haoyi. Among many other improvements, it does capture Ctrl+C.
I don't think Ctrl+C is even the right way to use Python REPL to abandon a mistyped command, there are several shortcuts probably will make your life easier here.
Ctrl+U should be the command you are looking for.
Erases the complete line.
Basically Ctrl+U will delete anything before the cursor, which should abandon the existing line completely if you are typing.
If your cursor is in the middle, you can use Ctrl+E to go the end first, and then Ctrl+U.
I tested in the shell, Python REPL and Scala REPL and they all work. For the curious minds:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With