PREV Mapping UP Commands NEXT Options

4.6: Shell Commands

Note that % is used in Ex commands to mean current file. If you want a % in your command, it must be escaped as `\%'. However if % is the first character, it stands as the address for the whole file. Similarly, `#' expands to the previous file. The previous file is the first file in :args listing. This defaults to the previous file in the VI sense if you have one window.


Execute a subshell in another window

:[x,y]!<cmd> Execute a shell <cmd> [on lines x through y; % is replace by current file, \% is changed to %
:[x,y]!! [<args>] Repeat last shell command [and append <args>].
:!<cmd> Just execute command and display result in a buffer.
:!! <args> Repeat last shell command and append <args>
<count> !<move><cmd> The shell executes <cmd>, with standard input the lines described by <count><move>, next the standard output replaces those lines (think of `cb', `sort', `nroff', etc.).
<count> !!<cmd> Give <count> lines as standard input to the shell <cmd>, next let the standard output replace those lines.
:[x,y] w !<cmd> Let lines x to y be standard input for <cmd> (notice the <sp> between w and !).
:<address>r !<cmd> Put the output of <cmd> after the line <address> (default current).
:<address>r <name> Read the file <name> into the buffer after the line <address> (default current).

PREV Mapping UP Commands NEXT Options