Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change a line in vim?

Tags:

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

like image 235
Cory Klein Avatar asked Apr 22 '13 17:04

Cory Klein


2 Answers

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

like image 172
knittl Avatar answered Sep 18 '22 00:09

knittl


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.

like image 24
Cory Klein Avatar answered Sep 20 '22 00:09

Cory Klein