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

How do I change text from the cursor to the end of the line?

Answer

C

Explanation

The C command deletes everything from the cursor position to the end of the line and places you in insert mode. It is equivalent to typing c$ but saves a keystroke.

How it works

  • C is a shorthand for c$
  • c is the change operator (delete + enter insert mode)
  • $ is the motion to the end of the line

Example

Given the text with the cursor on the b of brown:

The quick brown fox jumps

Pressing C deletes brown fox jumps and enters insert mode. Type dog sleeps to get:

The quick dog sleeps

Tips

  • Use D to delete to end of line without entering insert mode
  • Use c0 or c^ to change from the cursor back to the beginning of the line
  • The deleted text is stored in the default register, so you can paste it with p

Next

How do I edit multiple lines at once using multiple cursors in Vim?