Lukap
Lukap

Reputation: 31963

Override vim command for yank

The shortcut Y, for some reason, does not operate the way D and C do. Instead of yanking from the current position to the end of the line, Y yanks the whole line. Y does the same thing as yy.

Is it possible to override this functionality ? I want Y to acts as y$

Upvotes: 4

Views: 363

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172608

Learn how to look up commands and navigate the built-in :help; it is comprehensive and offers many tips. Pertaining to your question, :help Y offers this:

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$.

Upvotes: 3

Birei
Birei

Reputation: 36272

Use a map in Normal mode:

:nnoremap Y y$

Upvotes: 4

Related Questions