Used to do this with vim macros for lemmy, but a shell script is better.