Moving lines also requires two commands: dd (“delete”) and either p or P . To move one line, position the cursor anywhere on the line and type dd . For example, to delete 5 lines, type 5dd . Next, move the cursor to the line above where you want the deleted line reinserted and type p .
As others have mentioned: you can use d$ or D ( shift - d ) to delete from the cursor position until the end of the line.
Deleting a single line in Vim editor: To delete a line, follow the steps below: First, bring your cursor to the line you want to delete. Press the “Esc” key to change the mode. Now type, “:d”, and press “Enter” to delete the line or quickly press “dd”.
You could use something like d63G
to delete from the current line until line 63.
To delete from a to b use
:a,bd
from current to b use
:,bd
(where a and b in code are replaced by your numbers)
Same as the accepted answer, but slightly faster to type:
d63gg
deletes from the current line to line 63.
Why count lines? Go to the last line you want to delete and mark it by typing ma
which "marks" it with identifier "a". Then go up to the top line that you want to delete and type d'a
for delete to mark "a". Bam!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With