How to modify previous line in REPL - scala to modify the typing errors to save time compare to entering each line using up/down arrows
-
13-06-2021 - |
Вопрос
There are chances that some typing (in Ubuntu terminal - scala -version Scala code runner version 2.9.1) errors occur, example shown below where instead of (l: Int) (l: int) has been typed in parameters.
scala> class Rectangle (l:int, w: Int){
| val length = l
| val length = w
.
.
.
few more lines but still ... module Rectangle is not defined. Or sometimes enter command given and error shows up.
Is there anyway where directly that typing error can be edited / modified and rerun the code? It will save great deal of time otherwise I am entering line by line using up/down arrow.
Please guide.
Другие советы
I don't know if there is a better solution, but in my case I tend to use my usual text editor to write code snippet and paste them using the paste mode of the REPL (you can enter the paste mode thanks to the :paste
command).
Since Scala 2.13.2 multi-line editing is supported in the REPL based on JLine 3
JLine 3 supports multi-line editing, a better tab-completion UI, and more.
Configure keybindings with
-Xjline:emacs
(the default) or-Xjline:vi
; disable with-Xjline:off
History file is now
~/.scala_history_jline3
For example, to try multiline editing using vim keybindings start the REPL like so
scala -Xjline:vi
then enter a multiline definition and press up arrow key. Note how it gives
scala> class Foo {
| val x = 42
| }
class Foo
scala> class Foo {
| val x = 42
| }
instead of the old behaviour
scala> class Foo {
| val x = 42
| }
defined class Foo
scala> }