I'm trying to solve a problem with VIM. Here is what I'm trying to achieve:
I have a file with several lines in it. As I move my cursor from line to line, I want to send the current line as an argument to a Ruby script. The result of this script should be redirected to a VIM buffer which will be shown in a split window above the original text.
so far, I have been able to write a function that sends one line to the script and the results show up in a buffer above. I am not sure how to get this function to run each time the cursor moves to a new line and make the results update the same buffer. Any pointers would be appreciated.
My code:
function! BB()
redir => a
let str = getline(".")
let str1 = "\"" . str . "\""
silent execute "!${HOME}/scripts/test.rb " . str1
redir END
new
put! = a
endfunction
command! -nargs=0 BB echo BB()