As far as I know, all "good" scripts/programs start off with a shebang line as the first line:
#!/bin/bash
#!/usr/bin/env python
#!/usr/bin/perl
etc. Is it possible to pass that line to Vim in command
-mode to generically determine the program to use when executing the current file.
For example, perl file needs
:! perl%
Python,
:! python%
If the shebang is already there in the file, is it possible to replace the specific program before the % character (current file) with the shebang line/argument?
Of course, if the file is executable already :! ./%
works
The idea is to map a key so that, as you write code, simply hitting a shortcut key the file is executed; mimicking an IDE.
Once again, assuming the file is not (yet) executable, since you just started writing it in Vim.
:! chmod +x %
. Then, the rest is taken care of with the available shebang line already in place.