16 April 2011

Running Batch Files in Vim Ex-Mode

To modify a file using vim in ex-mode, you should be able to do this: vim -esn < modify.ex File.txt. The -esn option starts vim in ex-mode, a non-interactive session and no backup is created. The modify.ex file can contain a sequence of editing commands, ending with wq to write and close the file. However, in a Windows cmd session, the editing commands in modify.ex are executed but vim doesn't exit.

My workaround is to run a command (-c option) which uses vim's source command to run modify.ex: vim -esn -c "source modify.ex" File.txt.