To reverse the order of the lines in a file with vi, do the following: :g/^/m0