Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to use C-k to delete a line without sending it to the kill-ring.

I have the following on my .emacs file

(delete-selection-mode 1)

but this only seems to work for C-d (delete-char)

I have also read the solutions described in this thread: Emacs: how to delete text without kill ring?, but I didn't see anything that addresses this precise problem.

share|improve this question
Why does it matter if it goes to the kill ring? –  psusi Dec 8 '11 at 23:30
@psusi: Quite often I copy some text and then kill several lines one by one before yanking. When yanking, I don't remember how many lines I killed, and cycling through the kill ring to find the text I want to yank can be distracting. Either way, I'm also interested in learning how this can be done. –  user815423426 Dec 8 '11 at 23:40
add comment

1 Answer

up vote 3 down vote accepted
(defun delete-line (&optional arg)
  (interactive "P")
  (flet ((kill-region (begin end)
                      (delete-region begin end)))
    (kill-line arg)))

Maybe this is not the best solution, but it seems works. You may need to bind `delete-line' to some global key, such as

(global-set-key [(control shift ?k)] 'delete-line)
share|improve this answer
add comment

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.