Frequently we need to copy-paste a code snippet and compile-run it. The problem is that the lines of code are tagged by line number. So what utility to use to elegantly discard the line numbers?

You click on the link above the tagged code saying "show plain text".
Then copy/paste.

Frequently we need to copy-paste a code snippet and compile-run it. The problem is that the lines of code are tagged by line number. So what utility to use to elegantly discard the line numbers?

Your question is ambiguous at best. I might have to make some assumptions
If you are using an Unix/Linux base
If your copied data looks like:

Line one
Line two
    Space, line 3
Etc...

If you had it copied as it is to a file.
Then you can use sed, vim, or gvim, to make a substitution by using a regexp pattern.

sed 's/^[0-9]*\.//g' < copied_file > cleaned_file

or in vim/gvim

:% s/^[0-9]*\.//g
:w

Or you could try Gawk/Awk

awk '{for (i = 2; i <= NF; ++i){printf("%s ",$i);{if (i==NF){printf("\n");}}}}' filename
cut -d ' ' -f2- FILE

cut is my personal favorite for trimming one column, like a line number repeatedly. simple syntax, fast to type.

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.