The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

Holy war: Indent with tabs or spaces by SnappingTurtle2008-01-15 10:53:13
  Both. (Let me explain.) by bwkaz 2008-01-15 17:50:05
For the "normal" indentation (whitespace before code), tabs. That way, you can set your tab width to whatever you want, and the code that gets written will all reindent itself based on that tab width. That also happens to be the indentation that vim's autoindent code handles, at least for most languages I use.

But use spaces for the indentation used to line up multiple rows of text in a comment, when the first line of the comment started at the end of a line of code. That's because the text that you're going past has a fixed width, so if you use tabs and someone likes a different width for their tabs (e.g. 8 vs. 4), it screws up the alignment. Also use spaces for the indentation used to align e.g. comments on multiple structure members, for the same reason. You want the text to line up with previous lines, and because there are characters other than tabs before it, you need to use spaces.

(But DON'T use spaces all the way back to the left margin: use as many tabs as you need to get to the "normal" indent level for the current block, and use spaces from there.)

The nifty part is, this extra indentation that requires spaces is also the type of indentation that you put in manually, not the kind that the editor will (or can!) do for you. So if an editor was ever set up to work this way, it could be fairly simple -- e.g. in vim, it could be as simple as not setting expand-tabs when autoindenting, but when the user hits the tab key, turning it on for each tab key press.
[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)