Search code examples
swiftread-eval-print-loop

How to insert a newline inside a code snippet in the Swift REPL


I want to prepend a line to a snippet already entered in the REPL. The screenshot shows the cursor at the point that the newline should be inserted.

enter image description here

I do not know how to do this since hitting return will try to execute the snippet. I also tried CMD-Ret and Alt-Ret: same behavior. Is there any way to do this without retyping the entire snippet?


Solution

  • Control-V, Control-J does does the trick, similarly as in an interactive terminal. Control-V means "the next character should be treated literally" and Control-J generates a newline character.