3.12.10 Running shell commands


Next: 3.12.11 Getting help Up: 3.12 Using the vi Previous: 3.12.9 Including other files

  You can also run shell commands from within vi. The :r! command works like :r, but instead of reading a file, it inserts the output of the given command into the buffer at the current cursor location. For example, if you use the command

:r! ls -F you’ll end up with

You can also « shell out » of vi, in other words, run a command from within vi, and return to the editor when you’re done. For example, if you use the command

:! ls -F the ls -F command will be executed, and the results displayed on the screen, but not inserted into the file which you’re editing. If you use the command

:shell vi will start an instance of the shell, allowing you to temporarily put vi « on hold » while you execute other commands. Just logout of the shell (using the exit command) to return to vi.


Next: 3.12.11 Getting help Up: 3.12 Using the vi Previous: 3.12.9 Including other files

Matt Welsh
mdw@sunsite.unc.edu

READ  Linux Gazette Index Page