Vim provides different keyboard and command shortcuts. One of the most used action is delete
. Vim provides a lot of different use cases for deleting single and multiple lines.
Delete Current Line
Vim has cursor which will reside current active location. We can delete this line completely with the D
or dd
command.
D
Or
dd
Delete To The End Of The Current Line
Another useful shortcut for deletion is deleting from cursor to the end of current line.
d$
Delete To The Start Of The Current Line
We can delete from current cursor positions to the start of the current line with the following command.
d0
Delete Specified Number Of Lines
We can specify the line count we want to delete. We will use d
command two times where we will put the line count between d
commands like below. We will delete 5 lines from current line.
d5d
Delete Current Word
Words are separated with spaces from each other. We can delete current word where cursor locate can be delete with the following command.
dw
Delete To The End Of File
We can delete from current location where cursor blinks to the end of file with the following command.
:1,$d
Delete To The Start Of File
We can also delete from current location where cursor blinks to the start of the line with the following command.
:.,$d