Cory Klein
Cory Klein

Reputation: 55870

How do you change a line in vim?

Using vim I can change the word my cursor is on by tying cw. I can change the current character with cl. I can change everything inside some brackets with ci{.

I can even change the current and next line with cj. But how do I change just the line that the cursor is on?

I'm looking for something shorter or more efficient than one of these commands: ddko, 0C, 0Da, etc

Upvotes: 12

Views: 3327

Answers (3)

Cory Klein
Cory Klein

Reputation: 55870

The simplest way to do this is S, or SHIFT-s, as it changes the entire line regardless of the cursor location.

cc works similarly, but is arguably harder to type, with two consecutive non-home row key presses.

Upvotes: 8

Explosion Pills
Explosion Pills

Reputation: 191809

It seems like either ^C (or cc) (beginning of the line not counting whitespace) or 0C (very beginning of the line) would work best. Shift-c (capital c) means change everything from the cursor to the end of the line.

Upvotes: 3

knittl
knittl

Reputation: 265889

To delete the current line and start insert mode, use cc. To change everything that comes after the cursor, use either c$ or C

Upvotes: 22

Related Questions