Multiline input and whitespace



This issue came up when sending a function with a lot of blank lines in julia-repl. It can be reproduced like this:

julia> function f()
ERROR: syntax: incomplete: premature end of input

ie 3x RET after f(). Is this a bug? Should Julia wait for the end, or does it give up after a while? Is the threshold for the latter well-defined?


REPL seems to allow two newlines before deciding that the end of input is premature.
I do not know if it is intended, but you can cheat it like this:

julia> [i for i in

1-element Array{Int64,1}:

julia> [i for i in

1-element Array{Int64,1}:

julia> [i for i in

1-element Array{Int64,1}:

Here I obtained the second and third expression by going back the command history deleting 1:1], pressing two newlines, and reinserting 1:1]. Adding three newlines produces an error.


To clarify: the intent of this question is to establish whether this is intended behavior or a bug before opening an issue.

If this is intended, it should be documented (I could not find it, but perhaps I was not looking at the right place). That said, my life would be much easier if this was a considered a bug and got fixed accordingly, otherwise I will have to so some magic to remove newlines from code (but not strings etc).


As an aside, it would probably good to have a paste-mode. For this and also for pasting code including prompts.


There is a paste mode (bracket paste) which is automatically enabled when pasting (in most terminals). This can be opted into by plugin by sending the correct ansi sequence to the repl, see paste.


Corrected link

Edit: Looks like emacs has some support for this

Edit edit: more links:,


I think that @keno implemented this way back in the day and that it’s intentional. I’ve never used this feature personally, so I don’t really care if it stays or goes, but he may have more thoughts.


Yes, it’s intentional. It’s there so people get a syntax error when they have incomplete sequences but don’t think they do. As was mentioned, use bracketed paste mode for pasting expressions.


It does have the advantage that when someone gets frustrated and keeps hitting return, they eventually get an error and a new prompt instead of just a seemingly hung REPL.


Yes, it’s the “angry user detection” heuristic. Note you can always press shift enter to get a literal newline.


The shift+enter does not work for me. Does it work for anyone else?


I think Keno meant alt+enter.


I did, yes. Thanks for the correction.


Unfortunately in Windows console alt+enter turns on full screen mode.


Thanks. Bracketed paste solves my problems and I can see the rationale for this, so I am fine with it, just didn’t know about it.

But if I wanted to submit a PR documenting this (breaking out after 3 newlines, using Alt-Enter, mention bracketed paste mode), where should it go? Workflow tips?


It’s documented at


Meta-Enter is indeed documented (thanks!), but I could not find the documentation for

  1. bracketed paste mode, and
  2. breaking out after 3 newlines

there. Are they somewhere else? If not, where should they go?