While copying a code snippet from some sites and pdf,docs line numbers are also getting copied.I have to omit those line numbers in my text editor manually always. Any better way so that line numbers won't be copied?

Recommended Answers

All 6 Replies

When I copy code from DaniWeb, linenumbers never get copied.

commented: I see. But while copying from some pdfs,docs this problem arises. However i got a solution for that. Thanks ":)" +0

writing the code yourself? download the .jar file containing the code?

commented: I was just talking about copying and pasting the code snippets. .jar file for these are not available usually! +0

You could write a simple Java program to read a text file, delete any leading integers and write it back out. 15 minutes tops.

commented: This would be a peculiar way for doing this. However i found a nice and simple way. In sublime text2 using macros i am able to get this thing done easily. Btw thanks for your support. +0

sash_kp, just a remark on your comment on my reply:
your question stated
"copying a code snippet from some sites and pdf,docs"
the most sites that contain code snippets are more to 'look' at , rather than to copy-paste and use. the best, where they do give you examples that are decently coded, are the official pages, which do come with the code in downloadable form (even a lot of not-so reliable sites offer the code in .java files)
from pdf and docs ... well, if you're working with an e-book, and you have bought it, no doubt the author has given you access to some space where you can download the code used.
if you don't, chances are you downloaded an illegal copy, but how am I to know?

commented: Well Official sites and legally bought ebooks are not meant for copying and pasting stuffs. My question was very simple. Copying the code snippet and Paste in text editor to verify it works or not. No .jar file,no .java file nothing. Just copying,and whil +0

@stultuske

When I copy code from DaniWeb, linenumbers never get copied.

I copy code to test it out. The OP is usually rather vague in decribing his problem so I can test his code.

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.