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

How do I replace the contents of the entire current line?

Answer

cc

Explanation

The cc command deletes the entire content of the current line (preserving indentation) and enters insert mode. It is equivalent to S.

How it works

  • cc clears the current line content
  • Preserves the leading indentation if autoindent is set
  • Enters insert mode so you can type the replacement

Example

    old function content here

Pressing cc clears the line to:

    

(cursor in insert mode after the indentation)

Tips

  • S is a synonym for cc
  • 3cc changes 3 lines at once
  • C changes from cursor to end of line only
  • The deleted text is saved to the default register

Next

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