How can I add line breaks to a command at the prompt?

I know that when I copy a multiline command from the internet that has newlines it appears on the command line

$ something
> like
> this

Also I know that you can use \ to insert a newline at the very end of your command

$ like \
> this

But how can I add newlines in the middle of a command that I've already typed out?

For example, given

$ this long command that I want to split over multiple lines

How can I turn it into

$ this long command
> that I want to split
> over multiple lines

So far I've tried:

  • Using ctrl + v to insert a return character - just results in ^M being inserted
  • Typing \ return in the middle of the input (as you would do at the end of a line) - just results in \ being typed and then the command being executed.

1 Answer 1


Use Ctrl+V followed by Ctrl+J.

This inserts a linefeed character rather than a carriage return (which Ctrl+M or Enter would result in after Ctrl+V).

  • Ah, so are carriage returns the characters used to submit a command at the prompt? If so then it makes sense why Ctrl+V and Enter would insert one - I was initially assuming that since Unix files use linefeed characters as line endings that Ctrl+V and Enter would insert one of these. Aug 6, 2019 at 10:53
  • 1
    @JShorthouse The Enter key by itself sends the current line to the thing that reads it (the readline library). Prefixing it by Ctrl+V sends a carriage return. This does not mean that Unix uses carriage returns for newlines.
    – Kusalananda
    Aug 6, 2019 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.