Simple Macro - repeat your steps x times within vi create a macro called "a": qa then do all the steps you want in the macro by editing the file as you normaly would close the macro: q run the macro 10 times:10@a Replace spaces with:s/ /\1\r/ Sort a file within vi:sort Sort and remove duplicates:sort u Remove windows newline:%s/[[ctrlkey+v and ctrl-key+M]]//g Replace multiple spaces with tabs:%s/ /\t/g