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

How do I change from the cursor to the end of the word?

Answer

ce

Explanation

The ce command changes from the cursor position to the end of the current word. It deletes the remaining characters and enters insert mode.

How it works

  • c is the change operator
  • e is the motion to the end of the word
  • Only the portion from cursor to word end is deleted
  • Enters insert mode at the deletion point

Example

username

With the cursor on n (position 5), ce deletes name and enters insert mode. Typing _id gives:

user_id

Tips

  • cw behaves almost identically to ce (a special case in Vim)
  • ciw changes the entire word regardless of cursor position
  • cE changes to the end of the WORD (whitespace-delimited)
  • Use ce when you want to preserve the beginning of a word

Next

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