How to execute command inside vim?

bash, vim

Solution

There are multiple ways to do it. A primary question is "Do you want the output from the script in the file?"

If you want the output in the file:

:r!./shell.sh

If you don't want the output in the file:

:!./shell.sh

If you have the line `./shell.sh` in the file, you can include the output in the file with:

 !!sh

If you've done it before, you have more options.

If you save the command in a named buffer you have still more options.

If you want the script to have a portion of the file (edit buffer) as its standard input, you have an enormous number of options you can use in conjunction with either of these mechanisms.

Problem

I want to run shell script inside Vim editor. I heard it is possible but do not know. Command:`./shell.sh` inside `vim`.

Original source