Copy from script to console

[EDITED] When reviewing a working function, I often copy paste parts of it into my console, e.g. to make sure I understand which parts produce which outputs. I often have to do this in a copy-paste manner if I need to change some input. Right now it feels like a slow work flow to select the desired lines and then copy-pasting the selection to the console, so my question is: you can execute e.g. a full pipe over several lines just by placing the text cursor somewhere in the pipe and then pressing Ctrl+Enter, but is there a similar way that instead of executing just copies those lines to the console such that you can edit something before executing?

why not make a second scratch script, that you copy and paste code into, edit it, and then send that to console ?

@nirgrahamuk I realize that my introduction was misleading: I often use your approach when building functions, since then you may have to run some lines several times before you have reached the desired output.
But if I am sure I just want to execute some lines once, but with a minor modification, then I actually find this approach a bit slower than just manually selecting and copy-pasting directly into the console and doing the editing there. Right now I am reviewing a working function, so I just want to run some pieces of code once to check that I understand what is going on. In these cases I often need to fill in something extra, i.e. make small modifications that I mostly just have to do once. I have no interest in working on these code pieces in a separate script, since I want to see the full function in the main script while examining the outputs in the console - in this way I can see the outputs in their context and I can better understand what is going on.

I know I am just talking about seconds here, but I couldn't stop wondering whether I could avoid the text selection and copy-pasting in a way similar to code execution by Ctrl+Enter.

I don't know if there's a way to do what you're asking, unfortunately.

One thing I often end up doing is running the same piece of code a couple times with different modifications each time. In that case, if you've already run the code once but would like to run the same thing again with a slight change, you can use the up arrow key in the console to select the previously-typed command--and then you can modify it in the console before hitting enter to run it.

I realize that doesn't fully answer your question, and maybe you already knew about this feature, but I use it all the time for a similar scenario to the one you're describing so I though I'd mention it.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.