Skip to content

Quit R automatically

Jakson Alves de Aquino edited this page Dec 26, 2022 · 1 revision

If you are running R in an external terminal emulator and want to quit it automatically when quitting Vim, put in your vimrc (replace "nosave" with "save" if you want to save R's workspace):

autocmd VimLeave * if exists("g:SendCmdToR") && string(g:SendCmdToR) != "function('SendCmdToR_fake')" | call RQuit("nosave") | endif

If R is running in the built-in terminal, sending the command quit(save = "no") while leaving the editor will be meaningless because R will be killed by Vim/Neovim before having time to quit gracefully.