Code Formatting – Why Isn’t Rich Code Formatting More Common?

code formattinghistory

I was reading Code Complete and in the chapter on layout and style, he was predicting that code editors would use some sort of rich text formatting. That means, instead of code looking like this

Procedure ResolveCollisions
{ Performs a posteriori collision resolution through spatial partitioning algoritm }
(
  CurrentMap : SpriteContext,
  PotentialColliders: SpriteList
)
var Collider  : Sprite, 
    Collidee  : Sprite, 
    Collision : SpriteCollision
begin
  DoStuff();
end.

it could look something like this:

Procedure ResolveCollisions

Performs a posteriori collision resolution through spatial partitioning algorithm

Parameters

  • CurrentMap : SpriteContext
  • PotentialColliders : SpriteList

Local Variables

  • Collider : Sprite
  • Collidee : Sprite
  • Collision : SpriteCollision
    DoStuff();

I've seen syntax coloring and highlighting and even parentheses coloring, but nothing that looked like this in actual code. I was wondering if this sort of thing actually ever existed, or perhaps if it was decided that it didn't have enough benefit or that it was an entirely bad idea.

Have any of you seen richly-formatted code like this before, or know if the idea was ever considered and eventually rejected?

Best Answer

There is no technical reason that you couldn't. If text editors can do syntax highlighting, they could just as easily change other aspects of the display to highlight code.

However, it's one thing to have whatever is being typed change colors as the editor figures out what you are typing. Having the text suddenly change sizes and jump around while you are typing would get really obnoxious.

However, for a 'static' code display, you could easily beautify source code. For example take any halfway decent source->html converter, and add whatever font sizes and styles you like to the stylesheets, and you'll have rich formatted code.

Related Topic