What does C-u 0 mean in Emacs

emacs

What does C-u 0 followed by another command mean in general in Emacs?

For example,

I thought C-k and C-u 0 C-k were the same, but find out that

C-u 0 C-k kill the part of the current line before the cursor, while C-k kill the the part after.

Thanks.

Best Answer

Short answer

It provides number 0 to the next command.

Long answer

C-u in emacs called universal-argument. It's begin a numeric argument for the following command. Digits or minus sign following C-u make up the numeric argument. You can read more details about C-u by typing C-h k C-u or read online documentation here.

Understanding meaning of C-u, now you can know that, C-u 0 C-k and C-k are not the same. The first, C-k is called with an numeric argument, it's number zero. The second C-k is called alone. It leads to different behavior.

From Killing by Lines section of emacs manual:

The simplest kill command is C-k (kill-line). If used at the end of a line, it kills the line-ending newline character, merging the next line into the current one (thus, a blank line is entirely removed). Otherwise, C-k kills all the text from point up to the end of the line; if point was originally at the beginning of the line, this leaves the line blank.

...

When C-k is given a positive argument n, it kills n lines and the newlines that follow them (text on the current line before point is not killed). With a negative argument −n, it kills n lines preceding the current line, together with the text on the current line before point. C-k with an argument of zero kills the text before point on the current line.

Related Question