Vim comes with the :make command which is handy for compiling projects with Makefiles. But you can also set a different value for makeprg to do whatever you want for the current file. Of course you still to set up a key binding in your VimRC:
map <F5> :make<enter>
> instead of "save, exit, ./myscript, vi myscript".
This is something I see a lot of people doing. Obviously, it is not efficient. There is no harm in having another terminal window open where you run the script. If you are using SSH, you can use tmux or screen to have several terminals in one SSH session. And lastly, if you have to edit several different files, do not exit vim to switch files. Learn to use the :e and :b commands.
(The last advice is meant for the general audience and not directly to the previous post's author)