vi to delete from the beginning of the line till the cursor

TLDR: The easiest way is to do the following

  • use the navigate mode
  • set the cursor at whatever line you want
    • press dgg - this will remove everything from cursor to the beginning
    • press dG - this will remove all the lines from cursor till the end of the doc.

But why?

gg - goes to the begin of the document
G - navigates at its very end
d - delete mode

I was also looking for some combinations with the notation of d and line number, and when you are editing huge files like GB in size I found it bit annoying. Like to remove first 3 lines you need to do this :0,d3, but when the docu is over 1mln lines its tough for my eyes to read this crap...


I believe that the following should work (d^):

d^

This assumes that you only want to delete to the h even if there is white space in front of it. It will leave the white space.


Try d0. 0 denotes the beginning of the line.