Executing Programs in the Shell
call
ls
in the current directory. This is one-off command
call Vim's built-in command, shows the contents of the buffer list.
this
%
symbol is shorthand for the current file name.
if we're working on a Ruby file, we can execute it by this.
start an interactive shell session. you can execute several commands.
suspend the process that's running Vim and return control to bash.
list the jobs.
resume a suspended job, bringing it back into the foreground.
Using the Contents of a Buffer for Standard Input or Output
put the output from the {cmd} into our current buffer.
use the contents of the buffer as standard input for the specified {cmd}
:write !sh
,:write ! sh
: pass the contents of the buffer as standard input to the sh command.:write! sh
: write the contents of the buffer to a file called sh.
Filtering the Contents of a Buffer Through an External Command
[range]: The lines specified by [range] are passed as standard input for the {comd}, and then the output from {cmd} overwrites the original contents of [range]. or to put it another way.
-t','
: tell the sort command that fields are separated with commas.-k2
: to indicate that the second field is to be used for the sort.
drop us into Command-Line mode and prepopulates the [range] with the liens covered by the specified {motion}.
place cursor on line 2 and invoke
!G
, vim opens a prompt with the:.,$!
range set up for us.