3

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()
4

1 回答 1

0

我首先想到的是映射键动作。就像是:

map j j:call BB()<CR>
map k k:call BB()<CR>
于 2011-10-07T21:54:59.447 回答