I've got a set of files that contain notes written in reverse order:
Custom Enterprise plans require a Logentries Sales Order form, must be signed by the Customer, and once signed shall become legally binding and governed by this Agreement. Logentries may reject or terminate any sales order, at any time, at its sole discretion.
I'd like them to appear in this order:
Some of these files have couple of hundred entries - what's the easiest way of making this happen?
JoeJoe
![Logentries reverse order meaning Logentries reverse order meaning](/uploads/1/2/3/8/123899212/679284266.png)
2 Answers
Only tac
The command
tac
can do it.Call tac by Vim
If you want run it in Vim:
%
means all lines.!
runs external command.The backslash is necessary to escape the number sign
#
in '######'
.![Reverse Reverse](/uploads/1/2/3/8/123899212/389894048.png)
Only Vim
These commands replace new line by tab. If tab is present in the log, use another character instead of tab.
MarcoMarco
If there is a final newline at the end, the following command does what you want in Vim:
Which searches for lines starting with
###
takes the range from ###
til the next blank line and moves it to the top.If there is no final newline, it will probably abort with e.g.
E16: invalid range
, in that case you could adjust the regex like this:However, du to the last line missing, the first entry won't have a new line afterwards, so after all it might be easier to just add a single empty line add the end and use the first command.
Christian BrabandtChristian Brabandt