问题
When working with the node.js repl, is there a way to quit a continuation line that node is being over zealous with?
For example:
$ node
> {- -}
...
And pretty much everything you can type then gives you another continuation line. Ctrl+D quits the whole repl.
Obviously I don't want to go around typing {- -}
all the time, but I do find I often type something erroneous when I'm using the repl to experiment. Then I have to quit the repl, and loose all the bits in memory.
回答1:
You can also type:
.break
Type
.help
for more REPL options... the .clear command may also be useful because it breaks and clears the local context, in case you want to save yourself the trouble of exiting and restarting the repl.
回答2:
Sorry - I really should experiment more and Google less.
The answer (at least on Ubuntu) is Ctrl+C.
Ctrl+C first quits any continuation. Then if you hit it again prints
(^C again to quit)
Then quits, as it says.
In the interest of making this question more useful, just tested this and the same thing works in Python's repl, Guile. But doesn't work in Rhino, where it quits the repl entirely.
来源:https://stackoverflow.com/questions/6734712/node-js-repl-continuation-lines