11

I want to press M-j and have readline place my cursor on the next line without entering a command. Thus I should be able to go back a character onto the prev. line. This answer states that it cannot be done. I think it's wrong.

You can kill the newline character, and yank it. This achieves what I want to do. However I just can't create the binding.

To test this out type: echo <<EOFRETURNENTERC-cC-pM-1C-dC-c

Now you should be on a newline, type C-y. It does what I want! But what character is this? What binding works in an inputrc file?

EDIT: It turns out the character is a line-feed. Still not sure how to bind it.

cdosborn
  • 692

2 Answers2

17

You can type a newline character without having the line accepted by using readline's "quoted-insert", usually bound to C-v, followed by the newline character C-j.

"quoted-insert" is also useful for typing a tab character without invoking tab completion (C-vC-i).

rici
  • 4,003
1
bind '"\C-j": "\C-v\C-j"'
Tinmarino
  • 200