I use vim for bash scripting, and sometimes I write a one-time script. Usually, I don't want to create a new file, make it executable, execute it and then remove it.
For instance I open vim and type this:
#!/bin/bash
ll | while read line
do
echo $line
done
I 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?
<C-x><C-e>
and execute it on write, right?set -o vi
, you can hitEsc-v
to edit the command line in vi. ThenEsc-:wq
to execute.