I have a series of vim commands that write the selected block to a temporary file, run a function (knitcite) on that file, and then read in another file:
w! ~/.vbuf <CR>
!knitcite ~/.vbuf ~/.vbuf <CR>
r ~/.vbuf <CR>
If I've selected a block of text in visual mode before running the first command, it becomes
:'<,'>w! ~/.vbuf <CR>
passing the selected contents to the file, as I need. I can put this into a simple vim function in my .vimrc, but cannot figure out how to pass the contents of the visual selection to the function. If this were a single command instead of three commands, I could do this with a visual map, but not sure how to do it with three commands. something like:
command knitcite call Knitcite()
func! Knitcite()
exec "w! ~/.vbuf <CR>"
exec "!knitcite ~/.vbuf ~/.vbuf <CR> "
exec "r ~/.vbuf <CR>"
func
but this doesn't get any data passed in from the visual block. I guess I need to give an argument to my Knitcite function but cannot figure out what it would be. (Seems that this might be related to this SO question but I couldn't figure out how to generalize from that answer.)