To specify a range of data to pass to an external command, type this:
:1,5w !wc -w
would count the number of words within the range enclosed by lines 1 and 5. Type
:h 10.3 for more information on ranges.
You can also use
to replace the contents of lines 1 to 5 with the output of the command, which is useful when using external commands to filter text. (e.g. for sorting.) Type
:h ! for more information on filters.
If you wish to run an external command without having Vim pass text to its standard input, run the command like so: