18

Is there a way to delete a full line and start with an insert? Normally I would do:

  • 0 (go to start of line)
  • C (delete to end of line and start insert)

But is there a command to do the above without having to first enter the 0? Normally it's something like ciw or so to delete the 'wrapping' stuff (in this case the wrap is the line break).

The best I've gotten so far is now:

  • Shift-v (go to visual line mode)
  • c (change at the start)
1
  • There's always dd shift-o – bashBedlam Apr 23 '20 at 3:12
42

In the same way that yy copies the current line and dd deletes it, you can use cc to change it (i. e. yank it, delete it and enter insert mode). S is a synonym for cc.

12

cc does what you want, I think?

From :help cc:

["x]cc      Delete [count] lines [into register x] and start
            insert |linewise|.  If 'autoindent' is on, preserve
            the indent of the first line.
6

Three ways:

  • S [an abbreviation for cc]
  • Vs [line-wise selection, then substitute]
  • C [assuming the cursor is at the start of the line]

plus various ways to visually select all the text on the line followed by one of s or c.

Note that you can replace multiple lines using V, by moving the cursor down or using % to select a block, then s.

2
  • thanks, what does small s do in Vs ? V would put it into visual line-mode, and then s ? – David542 Apr 24 '20 at 5:19
  • s is I think short for "substitute" - it changes whatever is selected (without a selection it's equivalent to cl i.e. change one character). – Will Crawford Apr 24 '20 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.