Vi editor: What's the fastest way to delete multiple rows in a file?
If you mean you want to keep every 10th line and delete the rest:
%norm 9ddj
Explanation:
%
whole file
norm
execute the following commands in "normal mode"
9dd
delete 9 lines
j
move down one line (i.e. keep it)
note: this deletes the first row.
Adapted from http://www.rayninfo.co.uk/vimtips.html
Or using the global command:
- Duplicate the first line ggYP
:g/^/+ d9
Adapted from https://stackoverflow.com/questions/1946738/vim-how-to-delete-every-second-row
Or you could use awk
:
%!awk 'NR \% 10 == 0 || NR == 1'
:2,$v/0$/d
deletes the lines that don't end in 0
starting from the second one.