How to use vim non-interactively


1 min read

If you want to use some feature of vim non-interactively, you can use -c command argument. This will accept a vim command and will execute it on the input file.
You can use multiple -c arguments. For example:
vim -c '%s/data/DATA/g' -c 'wq' myfile
This will replace all occurrences of data with DATA in myfile automatically.
Tip: You can combine this with find command and have an automated find-and-replace script which acts on a set of files.