vimtricks.wiki Concise Vim tricks, one at a time.

How do I copy from the cursor to the end of the line?

Answer

y$

Explanation

The y$ command yanks (copies) text from the cursor position to the end of the line. Unlike Y which copies the whole line, y$ copies only the remainder.

How it works

  • y is the yank operator
  • $ is the motion to the end of the line
  • The yanked text goes into the default register

Example

hello world and more

With the cursor on w in world, y$ copies world and more.

Tips

  • Y in Vim yanks the whole line (unlike D which deletes to end of line)
  • Many users remap Y to y$ for consistency with D and C
  • p pastes the yanked text after the cursor
  • "ay$ yanks to the end of line into register a

Next

How do you yank a single word into a named register?