I have a bash script which takes a single argument and returns around 8-10 lines of text.
I’d like to be able to call this script from within vim. Ideally by highlighting a string of characters as the argument. I’d then like the output of the script to be displayed in a new pane.
I’m new to vim so I’m not sure if this can be done simply by creating a command in my vimrc file or if I need to create a plugin.
Any advice would be much appreciated.
after a bit of googling I’ve come up with
function! Foo(a1)
new
r !myscript a:a1
endfunction
This doesn’t quite work yet. It seems to pass the name a:a1 rather than the value.
I’d start with a simple function like so (note: the sample uses
echoas the script… Kinda lame… but you get the idea)and then a mapping for visual mode like;
This will call the script with the currently selected text when you hit QQ