简体   繁体   中英

In Scala REPL, how to discard partly written multi-line command?

On Unix Shell terminal, you can discard a typed command just by typing ctrl-c. Is there a way to discard a typed command on Scala REPL?

Ctrl-C still works but it would exit the Scala REPL, which is probably not what you prefer.

A couple of cases:

  1. If you're in the middle of a single-line command, you can hit Up button then Down to an empty command line.
  2. If you're in the middle of a multi-line command and the command is incomplete, you can simply hit return a couple of times to let the REPL interpret the consecutive blank lines as intention to start a new command. But, in case you worry about whatever you've typed might get executed, safest way would still be to hit Ctrl-C .

When you're writing an unfinished block you can enter two blank lines and the REPL will then skip your command and start a new one.

You may then still use up buttons to retrieve the lines you want to continue with in the new command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM