Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I am editing a single line, with my cursor at the indicated position:

$ abc ꕯ def ghi

I would now like to split into two lines and continue editing (like hitting ENTER would do in a text editor):

$ abc
$ ꕯ def ghi

Is there a way to do this in ZSH?

share|improve this question
    
Should abc be executed or do you want to insert a \n character at the cursor position? – mpy Feb 19 '14 at 23:30
up vote 3 down vote accepted

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 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.

share|improve this answer
    
This works. Thank you. – Owen Feb 20 '14 at 1:27

Here is a "vimmer" way in ZLE vi-mode that does not involve ctrl chords.

if your line looks like follows, and you are in normal mode: $ abc ꕯ def ghi

type this: DoESCp

total key presses: 4.

explanation:

`D` cuts from cursor to the end of the line and places cut string in register
`o`opens a new line places the cursor in it, and switches to insert mode
`<esc>` switches to normal pode
`p` paste register content.
share|improve this answer

Try using CTRL + M to solve your issue.

share|improve this answer
    
… and discover what it actually does instead. ☺ – JdeBP Feb 20 '14 at 0:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .