kill-whole-line works as I want. It cuts the line, and when I'm in org-mode it cuts the whole collapsed subtree.

What I need is just that as copy instead of cut. There is a multitude of suggestions here how to copy a whole line, which all work, but in org-mode they simply do not copy the whole collapsed subtree, they just copy the first line.

  • FWIW, a common Emacs idiom for emulating save-* commands is performing the corresponding kill command and then immediately undoing/yanking the kill, e.g. C-k followed by C-y, as the former kill modifies the kill-ring whereas the latter undo or yank does not.
    – Basil
    Commented Dec 20, 2017 at 18:31

2 Answers 2


How 'bout

(defun save-whole-line ()
    (forward-visible-line 0)
    (let ((start (point)))
      (forward-visible-line 1)
      (kill-new (buffer-substring start (point))))))

The (forward-visible-line 0) was taken from kill-whole-line's source code, and the kill-new was taken from copy-region-as-kill's source code (both of which should be easy to find via C-h f <function-name> RET).

  • Thanks for that code. It works as expected. I don't get it. If kill-whole-line is a part of emacs why not save-whole-line?
    – Jens Lange
    Commented Dec 14, 2017 at 17:27
  • Better would be a general "kill prefix" which you could use before any navigation command.
    – Stefan
    Commented Dec 14, 2017 at 19:26
  • How about making a suggestion on the emacs mailing list? I think you have a point here.
    – Jens Lange
    Commented Dec 15, 2017 at 13:44

To copy an entire subtree (including the parts that are hidden) use C-c C-x M-w which runs org-copy-special

To copy an entire subtree (NOT including the parts that are hidden) you can mark the entire section and run C-c C-x v which runs org-copy-visible

(these work for Spacemacs [email protected] but I believe they also work for regular emacs)

  • No, what I need is an mode-universal command like kill-whole-line. org-copy-special works quite differently than kill-whole-line. Combining org-copy-special with org-copy-visible works somehow but it is far from the universal behaviour of kill-whole-line
    – Jens Lange
    Commented Dec 14, 2017 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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