4

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.

3 Answers3

8

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

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

Marco Wahl
  • 2,796
  • 11
  • 13
  • Wow such a long keychord. –  Mar 24 '20 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](https://www.gnu.org/software/emacs/manual/html_node/emacs/Key-Bindings.html#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
  • `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 '22 at 04:52
  • A possible [reference to "backward kill line"](https://www.emacswiki.org/emacs/BackwardKillLine) – DawnSong Jun 11 '22 at 04:54
  • Given all basic buffer operations chords are even longer (I'm looking at `C-x k RET` for example) this doesn't seem long by Emacs standards at all. – Ev Dolzhenko Mar 16 '23 at 08:16
1

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

jidicula
  • 251
  • 4
  • 12
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.

phipsgabler
  • 195
  • 1
  • 6