Have read the GNU manuals on erasing, killing, and deleting.

In bash C-u deletes from the cursor to the beginning. I have searched and in much disbelief can't find out what the equivalent is in emacs? Very often in a buffer and in the minibuffer I wish to delete from the cursor to the beginning of the line.

  • 2
    The equivalent is C-SPC C-a C-w – Swedgin Mar 24 '20 at 10:12
  • Bash's C-u comes from GNU readline and can be configured via .inputrc. man bash and man readline refer to this key combo as unix-line-discard – Matt Kneiser Nov 30 '20 at 2:50

There is C-0 C-k or C-u 0 C-k.

See section (info "(emacs) Killing by Lines").

  • Wow such a long keychord. – run_the_race Mar 24 '20 at 11:19
  • 3
    Keys are a scarce commodity, so emacs doesn't want to "waste" one unless it's absolutely necessary. If you don't like what's offered, you can add the command(s) needed to do what you want to the key(s) of your choice: see Key Bindings in the Emacs manual. – NickD Mar 24 '20 at 12:53
  • 2
    I think this answer would improve slightly with the removal of the word "possibly" from the first sentence. I'd also put C-0 C-k first, since it seems easier to type to me. – Omar Mar 24 '20 at 17:21

I have C-<backspace> bound to the following function:

(defun phg/kill-to-bol ()
  "Kill from point to beginning of line."
  (kill-line 0))

Basically just the C-u 0 C-k from the other answer, see kill-line.


M-0 C-k should do what you want.

  • 4
    This seems to duplicate @marco's earliser answer. – Drew Mar 24 '20 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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