This tip may help someone - I’ve found it useful myself
Ever wanted to insert a new blank line into something you’re working on at the REPL?
Just pressing <Enter>
is going to execute the command!
TL;DR Use: <Esc>
followed by <Enter>
(or <Alt><Enter>
works too, which may be easier to type)
Note: this trick works mid-line to break a long line, too!
(on macOS to get <Alt><Enter>
working it may require an option to be set in your terminal application - look for options about the “Meta-key”)
For example, suppose you’ve just typed/pasted the following definition for the function f
:
julia> function f(x, y)
x + y
end
But you’d like to insert another line above x + y
.
Press the <Up>
key to get back what you previously typed, and move the cursor to the start of that line (or the end of the preceding line (denoted by █
):
julia> function f(x, y)
█ x + y
end
then press the <Esc>
key followed by <Enter>
, giving you:
julia> function f(x, y)
█
x + y
end
at which point you can make your edit:
julia> function f(x, y)
y = y >= 0 ? sqrt(y) : 0
x + y
end