How to delete from current line to to end of file in Vim
Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as “vi” with most UNIX systems and with Apple OS X.
Sometimes we need to delete all contents from current line or cursor to the end of file , below are several methods to do this
Method 1 : delete all lines to the end of file
d G(key d+shift+g)
where:
- d means “delete”
- G means “cursor go to the end line of the file”
This will delete all contents from current line
to the end of file.
Method 2 : delete all contents from current line to the end of file
: , $ d
(There is a space before “d”)
This way is useful in case sometimes you need to delete lines from line x to line y
: 10 , 100 d
Above will delete contents from line 10 to line 100
Method 3 : delete contents from current cursor to end of file
d
Ctrl
End
press key d
first , then press key ctrl
End
together.