In ZSH line editor, how to insert a new line?

In ZLE's emacs mode:

… the Control+V character (ASCII SYN) is bound to the quoted-insert widget. So just enter Control+V then Control+J (ASCII LF).

In ZLE's vi mode:

… the Control+Q (ASCII DC1) and Control+V characters are bound to the vi-quoted-insert widget. So again, in insert mode, just enter Control+V, then Control+J.

Remember:

Newlines in the middle of command lines separate commands. (In the terminology of the zsh manual: both newline and ; terminate a list.) Quote the newline if you don't want that.


Use ⌥↩︎ (Option / Alt+ Return), or ⎋, ↩︎ (Esc then Return).

This will only work if you've called bindkey -e previously or somewhere in your .zshrc.

Tags:

Zsh