Escaping to a shell command

Last revision August 2, 2004

Table of Contents:
  1. Editor choices on Unix
  2. Characteristics, advantages, and disadvantages of vi
  3. Basic text editing operations in vi
  4. Regular expressions
  5. File searching with grep
  6. More about regular expressions
  7. Intermediate text editing with vi
  8. Vi Quick Reference

You can run another command, such as ls, without leaving the editor. Just type

:! command_and_its_arguments <CR>

The single command (or pipeline) will be run, with output displayed on the screen as appropriate. You will then be requested to press the <CR> key again to re-draw the vi screen.

An alternative form allows you to run another command, capture its output, and insert that output into your file on new lines starting after the line the cursor is on. This usage is described in the section on moving text from one file to another.

Comments or Questions?