5

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
  • 2
    The equivalent is C-SPC C-a C-w
    – Swedgin
    Mar 24, 2020 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 Nov 30, 2020 at 2:50

3 Answers 3

9

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

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

6
  • Wow such a long keychord.
    – user27072
    Mar 24, 2020 at 11:19
  • 4
    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, 2020 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, 2020 at 17:21
  • C-0 C-k does not work on macOS Big Sur. Could you replace it with M-0 C-k? Further more, it will be better if you provide the link of your ref.
    – DawnSong
    Jun 11, 2022 at 4:52
  • A possible reference to "backward kill line"
    – DawnSong
    Jun 11, 2022 at 4:54
1

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

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

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

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

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

Your Answer

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