Skip to content

Instantly share code, notes, and snippets.

@stevenpollack
Created March 27, 2015 15:44
Show Gist options
  • Save stevenpollack/8766b1540c615db5aaf7 to your computer and use it in GitHub Desktop.
Save stevenpollack/8766b1540c615db5aaf7 to your computer and use it in GitHub Desktop.
Use Rscript to call the "rmarkdown" render function on currently open .rmd file
" have vimr-plugin call rmarkdown::render
function! RenderRMarkdown()
" set autoread to supress W11 warning:
" vim is going to complain about the rmd file already existing...
:set autoread
" get full file path via %:p
! Rscript -e "rmarkdown::render(commandArgs(TRUE)[2])" --args %:p
endfunction
" call RenderRMarkdown silently to suppress the "Press ENTER to continue" prompt
nnoremap <F2> :silent :call RenderRMarkdown() <CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment