I don't like having the numbers, (or the change in color) to the code snippets. While the idea is there for tutorial purposes (see line 5), it makes things a lot more difficult to copy and paste the code. While at first glance (in firefox) it seems that you are only copying the selected code (since the numbers don't get highlighted [see first picture attachment]), in practice, (firefox at least) also copies the numbers with the code (see second attachment).

I know that for me, I use code-snippets as a pretty regular part of my programming (hey, wasn't there a snippet for this...?), and it would greatly simplify my projects by just copy and pasting the snippet needed into my project.... If The numbers must absolutely be there, is there an alternative method to copy and pasting the code that won't include the numbers?

Recommended Answers

All 13 Replies

I am able to copy and paste the code snippets in both Internet Explorer and in Firefox into MS Notepad or MS Word without the line numbers with no problem. I'm using Windows XP. Additionally, when using my Mac, I am able to copy from the Safari web browser into XCode without line numbers.

However, both Dave Sinkula and now you have informed me that when you try copying/pasting, the line numbers get included. While I like the line number feature, obviously something has to be done because the ability to copy and paste without line numbers is a priority.

I'm not sure if it's a setting on your end or what :-/ If I can't get to the bottom of this, I will include a link on the page to toggle the line numbers on and off. To be perfectly honest though, I'm baffled because regardless of which OS or web browser I use, I am able to copy and paste just fine without the line numbers carrying over.

That is weird. I was under the impression that the numbers had no effect on the copy and paste operation... furthermore, the numbers do NOT get highlighted.... which is a real crazy situation, if someone (anyone) knows why this happens, PLEASE, let me know.

After talking to Dave Sinkula via PM, we came to the conclusion that it works fine when copying and pasting to a real text editor. It also works when copying and pasting into the vBulletin Standard Editor. However, the line numbers do get included when copying and pasting into the vBulletin Enhanced WYSIWYG Editor. I think this is more of a vBulletin bug than anything. I'll look into it.

Okay ... I'm getting people PMing me about this issue and people posting here, and it's getting really confusing. It always works for me, so to get to the bottom of this issue, I need to know exactly when it works and when it doesn't for who. Does it indent properly when you copy and paste? Does it preserve the line numbers all the time or just sometimes? Please post in this thread the exact issue and when it occurs.

Thanks!

Umn, the numbers are gone..... the indenting works properly.

Now about them colors....

Okay ... quick question, so the indenting didn't work with the line numbers?

Yes it did. See my first post's first attachment.

Lines 8-11 ;)

So what exactly was the problem with the line numbers? The line numbers copied over? Gah, now I'm even more confused :)

Right. Exactly. Indenting isn't a big deal. In fact, it wasn't until recently that code-snippets became indented. I was used to copying code from the snippets, and indenting what was needed..... it's nice now not to have to, but that was never the issue. The issue I had all along was that the numbers got copied to the clipboard, even when the numbers were not highlighted.... The numbers made a mess of things in any of the IDE's used (VB, in my case). Even someone doing some hard-core code in notepad would be stuck having to strip out the numbers (assuming this happens to anyone else). The numbers actually got copied to the clipboard (it wasn't an issue as to what program I was pasting it into.... the numbers were there)... that was my issue.

See no matter what program I used, the numbers never got copied to the clipboard. I was able to paste into Notepad, Wordpad, XCode, or any IDE in Windows or Mac and the numbers never got copied. But I noticed that indenting didn't copy over when using numbers but it did without.

Strange..... the good news is, you've removed the numbers.... so my problems are fixed.

Hmm ... I liked the numbers though. I think they could have been very conductive to discussing the code snippet and referring to parts of it. So I won't be happy until I can get the line numbers to work the way they are intended to. Obviously, however, the ability to copy and paste is a priority that outweighs little numbers in the margin.

magic div's?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.