Skip to content
Prev 3377 / 3656 Next

Open a text file with vi/vim in another Terminal

With Debian and macOS, the default editor (getenv("EDITOR") or 
getOption("editor")) is "vi" which opens vi/vim. The following instruction:

   fileREP <- file.path(R.home("etc"), "repositories")
   system2(getOption("editor"), fileREP, wait = FALSE)

works fine with Windows but is inappropriate in the Debian/RStudio/RCode 
console as it launchs vi/vim, warns about input and outputs and prints 
the text file WITHIN the R console and then does nothing. Closing vi/vim 
requires a manual action. In several tests, I even had to force R to 
recover. Hence My question is:

What is the system(), sytem2(), eventually file.edit() instruction that 
opens the text file with vi/vim in a NEW Unix terminal and allows to 
keep working in the R console?

Thank you for your advices.