Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deleting to the beginning of line when line starts with whitespace characters

Tags:

vim

I usually use d^ to delete to the beginning of line.

But if the line starts with space or tabulations, the deletion does not go all the way to start of line.

Example:

  foo foo

The line starts with two spaces, and the cursor is between the two "foo"

d^ deletes the first foo, but not the two spaces before it.

It is obviously useful most of the time, but what if I do want to delete everything?

like image 814
rcout Avatar asked Aug 14 '12 15:08

rcout


People also ask

How do I delete a space in vi?

To delete one character, position the cursor over the character to be deleted and type x . The x command also deletes the space the character occupied—when a letter is removed from the middle of a word, the remaining letters will close up, leaving no gap. You can also delete blank spaces in a line with the x command.


1 Answers

You can use d0 to delete to the real beginning of the line.

like image 133
GWW Avatar answered Nov 11 '22 23:11

GWW