Skip to content

Instantly share code, notes, and snippets.

@gonz
Last active December 19, 2015 01:09
Show Gist options
  • Save gonz/5874226 to your computer and use it in GitHub Desktop.
Save gonz/5874226 to your computer and use it in GitHub Desktop.
;; Join next line or join all lines in region
(defun smart-join-line ()
"Join the current line with the line beneath it or all region lines."
(interactive)
(if (use-region-p)
(save-excursion
(let ((start-line (line-number-at-pos (region-beginning)))
(current-line (line-number-at-pos (region-end))))
(goto-char (region-end))
(while (> current-line start-line)
(join-line)
(setq current-line (line-number-at-pos)))))
(delete-indentation 1)))
(global-set-key (kbd "C-S-j") 'smart-join-line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment