• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Indenting code in posted text

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I begin to read many threads here, it occurs to me that many of them include code snippets that would be easier to read if the indentation were preserved. I'm sure the style-conscious Sheriff Wheaton would agree. Is there a straightforward way to do this?
 
Trailboss
Posts: 23773
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh yes!
I usually use the HTML <PRE> and </PRE> tags around my code fragment to do this, although there are UBB CODE tags that can do this too (click on the "UBB Code is ON" link when you are writing a message for more info).
Some forums have HTML turned off, so you would need to use the UBB tags.

[This message has been edited by Paul Wheaton (edited August 27, 2000).]
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Ahh... I see," said the blind man!

Nice.
However, I did a brief survey of Ranch postings that include code that needs indentation and found that there are about 5 times as many such postings that don't use this than those that do (10:2). I wonder if a note on the text entry page to encourage this feature's use would help?
 
paul wheaton
Trailboss
Posts: 23773
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the text entry page you are thinking of?
(I fixed the tags in that message above - I should double check these things more often!)
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also bear in mind that CODE and PRE are not quite as smart as most people would like. They both "eat" empty lines, so if you want blank lines to appear in your code examples, you need to put a space or two at the start of the empty lines:
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sheriff: The "text entry page" I reffered to is the one I'm typing on right now to post this reply -- the one where UBB accepts a new topic or reply. What I was thinking of was maybe a note somewhere near this big key-in field (maybe just below the moose head?) sayin' somethin' like "If yer gonna put indented code in yer post, wrap it up with CODE tags like granny in her quilt."
 
paul wheaton
Trailboss
Posts: 23773
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That sounds like a good idea. The only downside is rooting through the source code to find where that particular page is created and stuff in a bit of html. How about to the left where it says "Smilies Legend"?
 
Bill Compton
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even better, 'cause it's closer to where you type.
 
reply
    Bookmark Topic Watch Topic
  • New Topic