Line-Numbers inside code-blocks

Can we have line numbers beside the code, inside the code-blocks ? It would be really useful while relating the compiler errors to the code. And the system should be such that, the line-numbers don't get copied, when we copy the code.