0

I do a lot of scripting using interactive R sessions on a remote machine.

Often times I want to paste many lines of code into R in one step from my clipboard, but I noticed that at a certain amount of lines/characters (roughly 50+ lines), the input I paste from my clipboard seems to get truncated (often times mid-line) resulting in a + sign in the console mmeaning that R is waiting for the current command to get its closing paranthesis.

This is very annoying as I need to either copy/paste in small chunks from the clipboard or write a tmp.r script to disk in which I can copy the entirety in and then source it.

Is there any way to allow a larger amount of code being pasted into the R console from the clipboard?

PejoPhylo
  • 469
  • 2
  • 11
  • Pasting code from the clipboard isn't the solution. Use an IDE with R support. There are tons that support working on remote machines (all of them support it, really: Vim, Emacs, RStudio and VS Code). At worst, use `source` ([or something similar](https://stackoverflow.com/q/12214963/1968)) to load your code instead of pasting it in. – Konrad Rudolph Jun 01 '23 at 09:13
  • Thanks for the input. In my experience, firing up a interactive session on the remote machine is the fastest and most robust way to solve certain problems quickly, for example if I have an unstable connection or the server is overloaded/unresponsive. While I appreciate your sentiment, I still think this question is valid. – PejoPhylo Jun 01 '23 at 09:26
  • 1
    Vim, Emacs and VS Code can still be configured to work in this scenario (in fact, it's the default configuration for VS Code). Your IDE runs locally and talks to the interactive session on the remote computer. But even if none of these work for you, the next best solution is *still* to use `source` (with some custom shortcuts) rather than copy and paste (not because there's something conceptually wrong with copy&paste but specifically because of the limitation you are observing). – Konrad Rudolph Jun 01 '23 at 09:32
  • I wasn't aware I can have my IDE run locally and have it talk to a remote machine, will try to set that up. Thanks a lot for the input :) – PejoPhylo Jun 01 '23 at 09:38

0 Answers0