Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

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. – Amelio Vazquez-Reina Dec 8 '11 at 23:40
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
what exactly is (control shift ?k) ? I copied the line verbatim in my .emacs file and tried using the CTRL+SHIFT+k keystroke and it didn't seem to work. – Marcus Junius Brutus May 30 '14 at 20:10
Depending on the window-system (esp. terminal), control+shift+k may not work. To test for specific key-binding is available, use C-H k, then type the keybinding whether it works. – cinsk Jun 9 '14 at 1:05
this kills only to the end-of-line. How about killing the whole line, but keeping the current cursor column? – towi Nov 17 '14 at 12:26

cinsk answer did not work for me on emacs 24.

But this did:

;; Ctrl-K with no kill
(defun delete-line-no-kill ()
   (save-excursion (move-end-of-line 1) (point)))
  (delete-char 1)
(global-set-key (kbd "C-k") 'delete-line-no-kill)
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.