8

Tip #840   Making vim oneliners

We can use vim to make changes to a file all in one command, for example

vim -c "5,10s/a/b/g | wq" filename

This will open the file 'filename' and replace all occurances of 'a' with 'b' on lines 5-10. The file will then be written and closed. To edit the file after the change, just remove the ' | wq' from the end of the command.