<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.5" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: How do you indent your code?</title>
	<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/</link>
	<description>Utterly random, incoherent and disjointed rants and ramblings...</description>
	<pubDate>Thu, 04 Dec 2008 20:48:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.5</generator>

	<item>
		<title>by: Mirko</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4991</link>
		<pubDate>Thu, 28 Jun 2007 16:42:56 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4991</guid>
					<description>@Rob speaking of "precious vertical real estate": I lately accidentaly ;) discovered that my LCD in the office allows rotation (instead of 4:3, it becomes 3:4). works great for coding, web browsing and writing documents. I also dislike 16:9 monitors, because menu and status bar waste even more space. in the 3:4 configuration, this effect is also diminished. 

my home LCD does not allow this rotation (but the next one certainly will), so I could not try that in Linux. anybody?</description>
		<content:encoded><![CDATA[<p>@Rob speaking of &#8220;precious vertical real estate&#8221;: I lately accidentaly <img src="http://www.terminally-incoherent.com/blog/wp-includes/images/smilies/icon_wink.gif" alt=")" class="wp-smiley" />  discovered that my LCD in the office allows rotation (instead of 4:3, it becomes 3:4). works great for coding, web browsing and writing documents. I also dislike 16:9 monitors, because menu and status bar waste even more space. in the 3:4 configuration, this effect is also diminished. </p>
<p>my home LCD does not allow this rotation (but the next one certainly will), so I could not try that in Linux. anybody?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Luke</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4979</link>
		<pubDate>Wed, 27 Jun 2007 06:29:07 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4979</guid>
					<description>Ok ladies! I fixed the coding issue. Now you should be able to use blank spaces, and be free not to escape HTML characters - and you will get nice code hilighting.

Just don't use the &#60;code&#62; tag - use &#60;pre lang="language"&#62; where language is the name of the language you want to use (like java, php, perl, csharp and etc..)

I made the code button default to java. Here are some examples:

Java:

&lt;pre lang="java"&gt;public class Foo
{
	// most awesome variable evar
	String bar;

	public Foo(String bar)
	{
		this.bar = bar;
	}

	public String getBar()
	{
		return bar;
	}

}&lt;/pre&gt;

PHP:

&lt;pre lang="php"&gt;&lt;?php 

	function foobar()
	{
		// do something awesome
		$foo = "bar";

		echo "the foobar: " . bar;
	}
?&gt;&lt;/pre&gt;

Lisp:

&lt;pre lang="lisp"&gt;; fibonacci series
(defun fib (n)
	(cond
		((= n 0) 	0)
		((= n 1) 	1)
		((+ (fib (- n 1)) (fib (- n 2))))
	)
)&lt;/pre&gt;

The supported languages are:

&lt;small&gt;actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css-gen, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80&lt;/small&gt;

Have fun. :)</description>
		<content:encoded><![CDATA[<p>Ok ladies! I fixed the coding issue. Now you should be able to use blank spaces, and be free not to escape HTML characters - and you will get nice code hilighting.</p>
<p>Just don&#8217;t use the &lt;code&gt; tag - use &lt;pre lang=&#8221;language&#8221;&gt; where language is the name of the language you want to use (like java, php, perl, csharp and etc..)</p>
<p>I made the code button default to java. Here are some examples:</p>
<p>Java:</p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Foo
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// most awesome variable evar</span>
	<span style="color: #aaaadd; font-weight: bold;">String</span> bar;
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> Foo<span style="color: #66cc66;">&#40;</span><span style="color: #aaaadd; font-weight: bold;">String</span> bar<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">bar</span> = bar;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #aaaadd; font-weight: bold;">String</span> getBar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">return</span> bar;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>PHP:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> foobar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// do something awesome</span>
		<span style="color: #0000ff;">$foo</span> = <span style="color: #ff0000;">&quot;bar&quot;</span>;
&nbsp;
		<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;the foobar: &quot;</span> . bar;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Lisp:</p>

<div class="wp_syntax"><div class="code"><pre class="lisp"><span style="color: #808080; font-style: italic;">; fibonacci series</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> fib <span style="color: #66cc66;">&#40;</span>n<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">cond</span>
		<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>= n <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> 	<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>= n <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span> 	<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>+ <span style="color: #66cc66;">&#40;</span>fib <span style="color: #66cc66;">&#40;</span>- n <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>fib <span style="color: #66cc66;">&#40;</span>- n <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The supported languages are:</p>
<p><small>actionscript, ada, apache, applescript, asm, asp, autoit, bash, blitzbasic, bnf, c, c_mac, caddcl, cadlisp, cfdg, cfm, cpp-qt, cpp, csharp, css-gen, css, d, delphi, diff, div, dos, eiffel, fortran, freebasic, gml, groovy, html4strict, idl, ini, inno, io, java, java5, javascript, latex, lisp, lua, matlab, mirc, mpasm, mysql, nsis, objc, ocaml-brief, ocaml, oobas, oracle8, pascal, perl, php-brief, php, plsql, python, qbasic, rails, reg, robots, ruby, sas, scheme, sdlbasic, smalltalk, smarty, sql, tcl, text, thinbasic, tsql, vb, vbnet, vhdl, visualfoxpro, winbatch, xml, xpp, z80</small></p>
<p>Have fun. <img src="http://www.terminally-incoherent.com/blog/wp-includes/images/smilies/icon_smile.gif" alt=")" class="wp-smiley" />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Luke</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4976</link>
		<pubDate>Wed, 27 Jun 2007 01:18:43 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4976</guid>
					<description>I didn't know it was called that either, until I &lt;a href="http://en.wikipedia.org/wiki/Indent_style" rel="nofollow"&gt;checked wikipedia&lt;/a&gt;. :P</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t know it was called that either, until I <a href="http://en.wikipedia.org/wiki/Indent_style" rel="nofollow">checked wikipedia</a>. <img src="http://www.terminally-incoherent.com/blog/wp-includes/images/smilies/icon_razz.gif" alt="P" class="wp-smiley" />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Starhawk</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4975</link>
		<pubDate>Wed, 27 Jun 2007 01:15:19 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4975</guid>
					<description>I use BSD/Allman despite a strong C background. It easier to read and makes more sense to me. BTW I never knew it was called "BSD/Allman" actually i never thought about calling it anything, it just works for me and is a habit now. haha</description>
		<content:encoded><![CDATA[<p>I use BSD/Allman despite a strong C background. It easier to read and makes more sense to me. BTW I never knew it was called &#8220;BSD/Allman&#8221; actually i never thought about calling it anything, it just works for me and is a habit now. haha
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Luke</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4973</link>
		<pubDate>Wed, 27 Jun 2007 00:27:05 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4973</guid>
					<description>[quote comment="4968"]Yeah, that is how it is supposed to look except I don't put the newline between the opening statement.  Basically, just like your first BSD/Allman excerpt but no extra newline when opening the code block.[/quote]

Actually, that is the BSD/Allman - the extra newline is just an artifact of the pre-wrap CSS attribute.</description>
		<content:encoded><![CDATA[<p><span style="padding-left: 10px;"><strong>Cocoa Crusty</strong> said:</span></p>
<blockquote cite="http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4968"><p>
Yeah, that is how it is supposed to look except I don&#8217;t put the newline between the opening statement.  Basically, just like your first BSD/Allman excerpt but no extra newline when opening the code block.</p>
</blockquote>
<p>Actually, that is the BSD/Allman - the extra newline is just an artifact of the pre-wrap CSS attribute.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Fr3d</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4971</link>
		<pubDate>Tue, 26 Jun 2007 23:16:56 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4971</guid>
					<description>The indenting style I use depends on the language I'm writing.

For PHP:
&lt;pre lang="php"&gt;if (condition) { 
	do_stuff();
} else {
	do_something_else();
}&lt;/pre&gt;

C# or Java:
&lt;pre lang="java"&gt;if (condition)
{
	do_stuff();
}
else
{
	do_something_else();
}&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>The indenting style I use depends on the language I&#8217;m writing.</p>
<p>For PHP:</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>condition<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
	do_stuff<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	do_something_else<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>C# or Java:</p>

<div class="wp_syntax"><div class="code"><pre class="java"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>condition<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	do_stuff<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">else</span>
<span style="color: #66cc66;">&#123;</span>
	do_something_else<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
				</item>
	<item>
		<title>by: Luke</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4970</link>
		<pubDate>Tue, 26 Jun 2007 22:47:25 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4970</guid>
					<description>Here is the CSS I use - can you fix it?

&lt;pre lang="css"&gt;code {
	color: black;
	background-color: #f8f8f8;
	border-top: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
	display: block;
	padding: 10px;
	font: 0.9em 'Courier New', Courier, Fixed, monospace;
	white-space: pre-wrap;
	white-space: -moz-pre-wrap;
	white-space: -o-pre-wrap;
}&lt;/pre&gt;

The pre-wrap stuff seems necessary to enforce white space - like tabs to stick. If I remove it, the browser eats all the tabs. But the same attributes seem to add extra blank space around each line, and cause the block to break if there is a single blank line inside.</description>
		<content:encoded><![CDATA[<p>Here is the CSS I use - can you fix it?</p>

<div class="wp_syntax"><div class="code"><pre class="css">code <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">color</span>: <span style="color: #000000; font-weight: bold;">black</span>;
	<span style="color: #000000; font-weight: bold;">background-color</span>: <span style="color: #cc00cc;">#f8f8f8</span>;
	<span style="color: #000000; font-weight: bold;">border-top</span>: <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span>;
	<span style="color: #000000; font-weight: bold;">border-bottom</span>: <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ddd</span>;
	<span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>;
	<span style="color: #000000; font-weight: bold;">padding</span>: <span style="color: #933;">10px</span>;
	<span style="color: #000000; font-weight: bold;">font</span>: <span style="color: #933;">0</span><span style="color: #6666ff;"><span style="color: #933;">.9em</span></span> <span style="color: #ff0000;">'Courier New'</span>, Courier, Fixed, <span style="color: #993333;">monospace</span>;
	<span style="color: #000000; font-weight: bold;">white-space</span>: pre-wrap;
	<span style="color: #000000; font-weight: bold;">white-space</span>: -moz-pre-wrap;
	<span style="color: #000000; font-weight: bold;">white-space</span>: -o-pre-wrap;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The pre-wrap stuff seems necessary to enforce white space - like tabs to stick. If I remove it, the browser eats all the tabs. But the same attributes seem to add extra blank space around each line, and cause the block to break if there is a single blank line inside.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Luke</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4969</link>
		<pubDate>Tue, 26 Jun 2007 22:42:03 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4969</guid>
					<description>Seriously - I think it's just some strange side effect of the CSS I use to format my code blocks - for some reason, any blank spaces will suddenly "end" the block. Weird.</description>
		<content:encoded><![CDATA[<p>Seriously - I think it&#8217;s just some strange side effect of the CSS I use to format my code blocks - for some reason, any blank spaces will suddenly &#8220;end&#8221; the block. Weird.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Cocoa Crusty</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4968</link>
		<pubDate>Tue, 26 Jun 2007 22:39:45 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4968</guid>
					<description>&lt;strong&gt;@Luke: &lt;/strong&gt;Yeah, that is how it is supposed to look except I don't put the newline between the opening statement (&lt;code&gt;if (1)&lt;/code&gt;), etc.  Basically, just like your first BSD/Allman excerpt but no extra newline when opening the code block.

Cocoa</description>
		<content:encoded><![CDATA[<p><strong>@Luke: </strong>Yeah, that is how it is supposed to look except I don&#8217;t put the newline between the opening statement (<code>if (1)</code>), etc.  Basically, just like your first BSD/Allman excerpt but no extra newline when opening the code block.</p>
<p>Cocoa
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Rob</title>
		<link>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4967</link>
		<pubDate>Tue, 26 Jun 2007 22:27:08 +0000</pubDate>
		<guid>http://www.terminally-incoherent.com/blog/2007/06/26/how-do-you-indent-your-code/#comment-4967</guid>
					<description>(felt I should contribute something relevant)

I very much prefer the K&#38;R style. Practically, I like not wasting a full line for an open brace (vertical real estate is precious), but philosophically I view the open brace as part of the 'if' (or 'for' or 'while' or whatever). When I type a close brace, I care about the type of block I'm closing, not the fact that it's a block.

Only blocks that I create purely for scoping get open braces on lines of their own.</description>
		<content:encoded><![CDATA[<p>(felt I should contribute something relevant)</p>
<p>I very much prefer the K&amp;R style. Practically, I like not wasting a full line for an open brace (vertical real estate is precious), but philosophically I view the open brace as part of the &#8216;if&#8217; (or &#8216;for&#8217; or &#8216;while&#8217; or whatever). When I type a close brace, I care about the type of block I&#8217;m closing, not the fact that it&#8217;s a block.</p>
<p>Only blocks that I create purely for scoping get open braces on lines of their own.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 2.218 seconds -->
