How can I delete multiple lines in vi?
I find this easier
- Go VISUAL mode Shift+v
- Select lines
- d to delete
https://superuser.com/questions/170795/how-can-i-select-and-delete-lines-of-text-in-vi
You can delete multiple(range) lines if you know the line numbers:
:[start_line_no],[end_line_no]d
Note: d stands for delete
where,
start_line_no is the beginning line no you want to delete and
end_line_no is the ending line no you want to delete.
The lines between the start and end, including start and end will be deleted.
Eg:
:45,101d
The lines between 45 and 101 including 45 and 101 will be deleted.
Sounds like you're entering the commands in command mode (aka. "Ex mode"). In that context :5d
would remove line number 5, nothing else. For 5dd
to work as intended -- that is, remove five consequent lines starting at the cursor -- enter it in normal mode and don't prefix the commands with :
.