PracticalVim Tip35 - yszheda/wiki GitHub Wiki
- invoke external programs in the shell by prefixing them with a bang symbol
- Comparison
- `%`: shorthand for the current file name
- filename modifiers
- `:shell`: start an iterative shell session
- Alternative of `:shell` and `:exit`: `` and `<fg></fg>`
- `:read !{cmd}`: put the output from the `{cmd}` into the current buffer
- `:write !{cmd}`: use the contents of the buffer as standard input for the specified `{cmd}`
- Comparison
- Effect of `:write !sh`: each line of the current buffer is executed in the shell
Example:
- shortcut for setting the range of a `:[range]!{filter}` command: `!{motion}`
e.g. invoke `!G` → vim opens a prompt with the `:.,$!` range set up for us
| Command | Effect | | `:shell` | Start a shell (return to vim by typing `exit`) | | `:!{cmd}` | Execute `{cmd}` with the shell | | `:read !{cmd}` | Execute `{cmd}` in the shell and insert its standard input below the cursor | | `:[range]write !{cmd}` | Execute `{cmd}` in the shell with `[range]` lines as standard input | | `[range]!{filter}` | Filter the specified `[range]` through external program `{filter}` |