This is another short Emacs tip that’s really a note to myself. The other day, I found myself in the middle of a line and needed to delete everything back to the beginning-of-line. I was sure there was some way to do that but I didn’t know what it was so I just sat on the 【Delete】 key until I reached the beginning of the line.
For the record, the correct way to do that is 【Ctrl+0 Ctrl+k】. That has a certain tractive logic since 0 suggests the beginning-of-line (at least to those of us with vi experience) and, of course, 【Ctrl+k】 means kill the rest of the line. It also has the advantage that it’s easy to type.
Thanks for the tip but I don’t understand why this, is not mapped to Ctrl+u just like it is in my terminal …
Documentation to kill-line says:
“Kill the rest of the current line; if no nonblanks there, kill thru newline.
With prefix argument ARG, kill that many lines from point.
Negative arguments kill lines backward.
With zero argument, kills the text before point on the current line.”
Ctrl- provides that digit argument to the kill-line, that is why it uses Ctrl-0 Ctrl-k, not Ctrl-u Ctrl-k. You can also use Ctrl-u 0 Ctrl-k.
Of course Meta-zero Control-k also works, if that’s preferable on your keyboard.
I mean, why it is not bind to Control U by default in emacs (as it is for the terminal). Actually I didn’t know about this command, so thanks again for the tip ;)
Because Ctrl-u has a special meaning in Emacs–it’s the universal argument. Otherwise, that would be a logical choice, I suppose, except Emacs tends to do things the way they did here: have a keybinding for some general command and a prefix to modify it.
I usually do C-SPC C-a C-w, this saves me a keystroke, thank you. But if you want to kill until the beginning of the paragraph I think you have to do C-SPC M-a C-w or is there a better solution?