Selecting code when people paste code here

(I've got to ask, because I can't believe no one else is thinking it)

I appreciate that when you post code you put it like this:

example code

But if it is several k bytes in size, how is it done?

For me, I have to click the left most part of the line, drag select it all - which means moving the mouse right beyond the end of the line and ........ waiting. (and waiting and waiting)

Any slight movement up or down, you get the other stuff selected as well.
Not a bit deal as the thing is still scrolling to the right.
Then when at the end, you have to position the mouse at the end of the line (while holding the button down) then only select the code.

Press ^c to copy it.

There must be an easier way.

type three back ticks

paste code

type three back ticks

```
paste
```

I start dragging at the start of the line, then drag down to the next line. So dragging vertically rather than horizontally. On import, remove anything I copied too much if needed.

Steve, I am saying for taking the code others have posted.

Not putting code here.

Wrong way around. Sorry.

triple click inside the code

OR

highlight 1st part then press shift + end

2 Likes

If you take more than the code, how to you clean it up before importing it to node red?

Seems to introduce another step/phase.

Ah!
(Is that mentioned anywhere in the docs for this place?)
Noobs would/may find it handy.

Never thought of that. Shall have to try it and hope I remember next time I am looking at a lot of code.

(Second option)

Oh yeah. Ok. That's fair enough.

Some other forums which are 99% like this have a copy button above any posted code which is handy.

But tripple click does seem like a handy one to remember, as I have my hand on the mouse at that stage of things.

The second one means hand relocation.

Use you other hand? :smiley: :smiley: :smiley:

Some further clarification...

SINGLE LINE CODE ...
triple click inside the code
OR
highlight 1st part then press shift + end

MULTI LINE CODE...
highlight 1st part
scroll to end
hold shift + click at the end of code

Thanks Steve.

I went off and found a bit of big code.

tripple click works.

Woo hoo! Now I need to remember it.

@Trying_to_learn I've just enabled an option in the forum that adds a copy-to-clipboard button to the top right corner of any code block when your mouse hovers over it:

This is a new feature that got added in the most recent version of the forum software and I had been waiting for our forum to be upgraded to it. Your post reminded me to go check, and sure enough, the option was there.

I hope that helps.

5 Likes

And another... If you have two windows open - one with flow and one with the forum (or other source of code) - if you use the triple click - you can then just drag the code onto the flow editor desktop to import it.

3 Likes

Thanks Nick.

But the (afore mentioned) triple click when the code is one line seems to be the only way.

As said, other forums which look 99% like this put a copy button above the one line of code.
See picture for example for what it kind of looks like.

Ah man, i didn't know you handled contextual drag n drop. :heart:

its already done Andrew :slight_smile:

Super cool!

I shall have to try to remember that too...... (So much to remember!)

I beg to differ...... There isn't a button visible on the screen shot I posted.

Maybe for short bits of code. But 20k sizes.... I don't see the button.

Sorry.

It is only visible when I moved the mouse over the code.

And I would say it is a new thing.

I just said - I have enabled exactly this option in response to your post... you should see it right here

Can you see the copy button when you hover over this text?

I said:

I've just enabled an option in the forum that adds a copy-to-clipboard button to the top right corner of any code block when your mouse hovers over it:

Yes I can.

Sorry. I saw @Steve-Mcl's post, and shot myself in the foot.

What caught me was I didn't have the mouse over the code.

And when I was going back to get another screen shot to show him, I noticed it started to show up.

Again, thanks.
It is very much appreciated.

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