Delete before the start of the line when the line starts with space characters

I usually use d ^ to delete before the start of the line.

But if the line starts with a space or tables, the deletion does not reach the beginning of the line.

Example:

foo foo

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

d ^ removes the first foo, but not two spaces in front of it.

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

+44
vim
Aug 14 2018-12-18T00:
source share
3 answers

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

+93
Aug 14 '12 at 15:35
source share

like @GWW and

  • use c0 to remove the real beginning of the line and switch to insert mode.
  • c^ - delete the first non-empty character and switch to insert mode.
+24
Jun 28 '13 at 8:33
source share

You can also use | to get column 0 of the row, which can be used in combination with d as d| to delete in row 0 column.

Source: http://hea-www.harvard.edu/~fine/Tech/vi.html

+1
Aug 02 '16 at
source share



All Articles