LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback
User Name
Password
LQ Suggestions & Feedback Do you have a suggestion for this site or an idea that will make the site better? This forum is for you.
PLEASE READ THIS FORUM - Information and status updates will also be posted here.

Notices


Reply
  Search this Thread
Old 04-14-2007, 10:22 PM   #1
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
'line numbers' option in [code] tags


im wondering if somehow you can add an option/field to either the code or quote tags to automatically add line numbers to each line.

i think it would make things a little easier when referring to another poster's code, if the line numbers are inserted at the beginning of each line. this could also be useful in the quote tag, if someone is posting a configuration file, for example.

to use it one would have to change their code/quote tag, ie [code uselinenumbers]...[/code]

i searched for what im talking about, and found one thread on it. however, i would like to touch on the topic again, 6 years later. i just dont think its necessary to have to use the suggestion posted on the mentioned thread to implement this. then again, the mods might think my idea is not necessary

thanks for your time.

Last edited by nadroj; 04-14-2007 at 10:26 PM.
 
Old 04-15-2007, 12:56 AM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
I'm thinking it might be a good idea to make the default be (for code, not quote) that the line numders are there.
 
Old 04-15-2007, 01:05 AM   #3
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Original Poster
Rep: Reputation: 60
a big difference between the code and quote tags is that code preserves spacing. some people will prefer this when, for example, showing the output of a command, where spacing makes it much more readable. so if someone wants to print some simple (afew lines) output (not programming-related) they may use the code tags. however, it would be unnecessary to have the line numbers displayed right? same would go for a simple few lined-script.

the point im trying to get at is i think it would be best that the tags stay as is, with an extra (explicit) option specifying that the output should have line numbers added.

of course i dont run the show here.. im just giving my input.

thanks for your interest, keep the ideas coming.

Last edited by nadroj; 04-15-2007 at 01:08 AM.
 
Old 04-15-2007, 03:32 PM   #4
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
I think that's a great idea. I can see one difficulty, though: any implementation of this would probably make it so that copying and pasting the code would drag the line numbers with it. So I suggest that if this feature is implemented, there be a user-toggle-able option to show or not show line-numbers. That way if I'm reading some interesting code (with line-numbers) and want to copy it into Emacs, I can just click the toggle off and be all set to copy (without line-numbers).
 
Old 04-15-2007, 04:41 PM   #5
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Personally I would not want to see line numbers, I often copy/paste code that is posted to find out what is wrong with it (or why it works).

If they (the line numbers) can be optionally shown I wouldn't mind this new feature, be it that not showing them would be the default.

There is a way around the 'referring to' part:
Code:
Other tags inside the code tags are legal, bold for instance.
They can be used to highlight the parts that you are referring to.
Just my 2c.

Last edited by druuna; 04-15-2007 at 04:42 PM.
 
Old 04-15-2007, 05:30 PM   #6
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Original Poster
Rep: Reputation: 60
@druuna:
i agree i wouldnt want it to be the default. as ive mentioned previously, in order to enable it, the user would add an option/field to the tag in question, explicitly saying they want them to be shown

@taylor:
you make a valid point about copying and pasting the content of the tag. it would definetly be a hassle if the user posted the tag with line numbers, and you copy and paste them somewhere else. it would be your job to have to remove the numbers, which isnt fair and would be a pain.

i would like the line numbers to, again, by default never be shown. however, if the poster gives the extra option, then the content in the tag will (by 'default') have line numbers shown. when other people go to view the post, they can simply click a button to hide them.

better yet, when the line numbers are told to be shown, they will be displayed in a second 'table' to the left of the code/quote tags. the content of the left table will just be a number corresponding to the line number in the table on the right (the content one). this way if you copy everything from the code/quote tag, you will only get its contents, and not the line numbers.

well i hope one of the 'big wigs' get around to reading this post so we can hear their thoughts

thanks to everyone for their interest and input.

Last edited by nadroj; 04-15-2007 at 05:33 PM.
 
Old 04-15-2007, 05:39 PM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could use "cat -n" to add line numbers to the code and cut and paste that into the code block.

This would allow you to refer to a code fragment instead of the full file.
Code:
   222  extern unsigned const int tuner_count;
   223
   224  extern int microtune_init(struct i2c_client *c);
   225  extern int xc3028_init(struct i2c_client *c);
   226  extern int tda8290_init(struct i2c_client *c);
   227  extern int tda8290_probe(struct i2c_client *c);
   228  extern int tea5767_tuner_init(struct i2c_client *c);
Which for published code would be a handy to the readers of the post with copies of the file (as in kernel source code).

I would love to see something like [code=/path/to/source/code.c] to add reference information the way you can refer to a poster, and suggested this or something similar, but it would be to much trouble to implement I guess.

----

After posting, I read the link and the same thing was suggested in the referred post.

Last edited by jschiwal; 04-15-2007 at 05:41 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Using tags to browse through source code LXer Syndicated Linux News 0 01-31-2007 10:54 PM
Grep's line numbers parsed into one line of output. judgex Programming 8 08-14-2006 04:22 AM
printing line numbers for code bauer172uw Programming 3 04-13-2006 11:10 PM
Prepend # for certain line numbers in VI twantrd Linux - Software 3 09-05-2005 01:27 PM
printing line numbers? fisheromen1031 Programming 1 07-27-2004 02:19 PM

LinuxQuestions.org > Forums > LinuxQuestions.org > LQ Suggestions & Feedback

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration