I wrote a while ago about using M-^
to join the current line to the previous line. In fact, when editing I find that I most often want to join a line to the following line. I used to do this by using C-e
to move to the end of the line and then C-d
to delete until I got the next line joined to the current one. It is easier to do this with a single key using a simple function, which I set to C-j
. Add the following to your emacs config file:
;; join line to next line (global-set-key (kbd "C-j") (lambda () (interactive) (join-line -1)))
You can keep hitting C-j
to keep joining the next line.
Update
I originally used M-j
as the keybinding for this, but Kaushal Modi pointed out in the comments that C-j
is a better choice.