Can't run many commands in Vim visual mode from outside
I have the following commands in my README file:
./Setup ... ./Setup ... ./Setup ...
I want to run them by typing codes visually and then running them.
I am running unsuccessfully
: '<,'> !
Current code after Luke comments in his answer
My code in .vimrc that I was unable to get:
vmap <silent> <leader>v y:exe '!'.join(split(@", "\n"),';')<cr>
I am trying to make a keyboard shortcut for
v yy
How can you get the above command to work so that you can run file commands directly in Vim?
a source to share
This might be an oversimplification, but why not just do:
: e README :%! bash
Filters the current file with bash, executing each line as a command. The current buffer is replaced by the output of all commands in the file.
It might be useful to do :w RESULTS
to save it as a different file so you don't accidentally overwrite the original:
: e README : w RESULTS :%! bash
You said you wanted to do this with a visual selection that would work just as well. After you choose what you want to execute, enter :
. '<,'>
will be automatically added to the current command. '<
is the mark at the beginning of the current selection, while '>
is the mark at the end of the current selection. You can simply run only the commands you have chosen in the same way as above:
: '<,'>! bash
This will replace only the selected commands with the result of those commands.
a source to share