vi – useful commands

1. execute shell and put output into edited file

In this example I am listing current directory and add file names into edited file

:r!ls -1

2. execute shell command

:!command_to_execute