Is there a specific historical reason for this?
Background — (you can skip this part if you already understand the question.)
vi users will know,
y is the "yank" command—it yanks (copies) the text specified by the following movement command.* Thus
ye yanks to the end of the word,
y0 yanks from cursor position to the beginning of the line,
y_ yanks the entire current line,
y$ yanks from cursor position to the end of the current line, etc.
d (delete) command and the
c (change) command can both be used with all of these motions as well.
dd is a synonym for
d_ and deletes the entire current line. Likewise,
cc is a synonym for
c_ and will change the current line (i.e. it will delete all the text and put you in insert mode at the beginning of the line).**
The "yank" command follows this convention;
yy will yank the entire current line just like
There is another set of synonyms:
D is a synonym for
d$ and will delete from the cursor position to the end of the line.
C is a synonym for
c$ and will change the text from the cursor position to the end of the line, placing you in insert mode to type the new text.
Y is another synonym for
y_ and will yank the entire line, not just from the cursor to the end of the line as you would expect from the
I understand that in Vim it was kept this way to preserve backward compatibility with
vi, as is mentioned in the Vim help under
If you like "Y" to work from the cursor to the end of line (which is more logical, but not Vi-compatible) use ":map Y y$".
So this is a holdover from
But, why was the command designed that way in the first place? Was there any logic to it ever?
*Specifically it places the text in register 0 and points the unnamed register at register 0.
**Although it's not relevant to my question,
S is another synonym for