I have tried to follow the following:
How to delete selected text in VI editor
but
5dd
gives
E492: Not a
If you want to delete a range AFTER a specific line trigger you can use something like this
:g/^TMPDIR/ :.,+11d
That deletes 11 lines (inclusive) after every encounter of ^TMPDIR
.
Type :set number
(for numbered lines).
Press the Esc key to make sure your are not in an edit mode.
Place the cursor on the first line to be deleted.
Enter :5dd
.
The current line, and the next four lines should be deleted.
Alternately, if you have line numbering turned on...
Press the Esc key to make sure your are not in an edit mode.
Enter :#,#d
where '#' stands for the beginning and ending line numbers to be deleted.
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 :
.
I find this easier
https://superuser.com/questions/170795/how-can-i-select-and-delete-lines-of-text-in-vi