I use vim for bash scripting. the thing is sometimes I don't want to create a new file, make it executable, execute it and then remove it. I mean the scripts which are going to be used only once.For instance I open vim and type this:#!/bin/bashll | while read linedo    echo $linedoneI did not save this file, I just use vim to simplify bash-scripting. I know I can execute a bash command via ! in vim. But what about executing everything that is in the buffer?
Execute bash script from vim
command line;external command;bash
I wrote a pretty extensive answer about this over on stack-overflow. The basic idea is that since the write command is about writing not saving, you can write the text in your buffer into an external program, such as python or bash. In your case, you would want to do something like::w !bashor:w !shThese commands literally just write the text in your buffer directly into the program you specify with !, which is convenient because then you do not need to save a file. Of course, you may also do something like::w | !bash %which saves your file and then runs it as a bash script. You can choose whichever one makes more sense for you.