I would like to delete every other line from a Vim buffer, starting with the second one, i.e., lines 2, 4, 6, etc. For example, if the buffer’s contents is:
a
As another approach you could also use python if your vim has support for it.
:py import vim; cb = vim.current.buffer; b = cb[:]; cb[:] = b[::2]
b = cb[:] temporarily copies all lines in the current buffer to b. b[::2] gets every second line from the buffer and assigns it to the whole current buffer cb[:]. The copy to b is necessary since buffer objects don't seem to support extended slice syntax.
This is probably not the "vim way", but could be easier to remember if you know python.