Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

It's exactly the same as eclipse Shift+Enter.

E.g. I have a some text:

Hello, *everyone.
I'm Freewind.

The * in the first line is the cursor. Then I press some key shortcut, it becomes:

Hello, everyone.
I'm Freewind.

Notice there is a new line in the second line, and the cursor is in the new line.

What's the key shortcut can I use?

share|improve this question

migrated from Sep 4 '11 at 0:16

This question came from our site for professional and enthusiast programmers.

I always use C-e and then enter. – Milan Sep 2 '11 at 18:38
up vote 13 down vote accepted

C-e C-m


C-e C-j

Both will move to end of the line and add newline. The second will also indent.

share|improve this answer
Can I map a key to do this job, so I just need to press once? – Freewind Sep 2 '11 at 18:42
That is a key mapping. Emacs allows binding commands to key sequences and most commands are two keys. It's generally a bad idea to bind to one key since most of the one key bindings are taken by emacs fundamentals. – Ross Patterson Sep 2 '11 at 18:46
C-e invokes move-end-of-line and C-m invokes newline – Dror Jun 15 '14 at 19:47

For completeness here is a function:

(defun end-of-line-and-indented-new-line ()

(global-set-key (kbd "<S-return>") 'end-of-line-and-indented-new-line)
share|improve this answer
Thank you, but how do I use it? Just map a key to this function? Can I map "Shift-Enter" to it? – Freewind Sep 2 '11 at 18:57
@Freewind answer updated – Trey Jackson Sep 2 '11 at 19:54
@Trey Jackson Thank you. – phimuemue Sep 2 '11 at 23:04
If you use comment-indent-new-line instead, it will also insert the appropriate comment characters if you're currently inside a comment. – phils Sep 3 '11 at 0:19

You can make something akin to a keyboard macro like this.

(global-set-key (kbd "<S-return>") "\C-e\C-m")

or indeed:

(global-set-key (kbd "<S-return>") (kbd "C-e C-m"))

to avoid using two different kinds of syntax for keys.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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