24

Somewhat inspired by this question about a graphical programming environment. I don't think that C++ or C# are really conducive to this type of environment, but perhaps there's something halfway there.

Lot's of IDEs that I've used will use syntax highlighting to change the foreground (or even the background) colour of text for keywords, strings, comments, etc...

Are there IDEs out there that will highlight larger syntactic structures? Here's an example of what I'm thinking of.

Example code structure http://img256.imageshack.us/img256/9441/codestructure.png

(Please don't comment on my poor choice of colours... I'm not a graphic designer for a reason.)

While it's not a graphical drag-and-drop environment, the highlighting would still give an overall view of the structure of the code. Personally, learning C# after years of C++, I still catch myself tripping over the fact that at the end of a file you usually have the end of a class and the end of a namespace, so the end of a function is two-levels in. (In a C++ code file, the end of a function is usually at the top level of indentation). I help myself out there by throwing in little comments at the close brackets:

    } // end class 
} // end namespace

But it seems to me that some automatic colouring would make that completely unnecessary. Anyway, has this been done already? Bonus if it's an add-on to Visual Studio.

4
  • Never seen anything like it, but I'll take two!
    – Jon B
    Commented Mar 18, 2009 at 21:05
  • Kind of simillar to that code rush addin MS released(I think it was code rush they did it with) but it highlights syntax blocks although it does it by using lines btw the elements....
    – JoshBerke
    Commented Mar 18, 2009 at 21:07
  • I'd love that. The only issues I see is indents aren't strictly required as part of the language specification (as opposed to say Python) so it'd look a little weird if for whatever insane reason you'd choose not to index and turn off VS auto-formatter
    – Davy8
    Commented Mar 18, 2009 at 21:27
  • Davy8 - My implementation of the concept (Codekana) doesn't look at indentation, it analyzes the syntax. It works just fine with most common indentation schemes people use, and with most weird but sensible ones too.
    – jonbho
    Commented Mar 21, 2009 at 20:56

11 Answers 11

16

I'm the author of Codekana. Indeed, what you describe above was the main goal for the product. BTW, I'm about to publish an article about the "making of" and the underlying technology, which is pretty nifty. It will probably be available next week (March 26, '09 or so). Recommended reading, if I may say so myself.

The reason Codekana only provides outlines, instead of a colored background, are limitations in VS's text rendering extensibility. I will hopefully be able to implement a solid-background version at some point in the future, although it will definitely require serious hacking and "rocket surgery".

I would have commented above, instead of providing another answer, but my reputation doesn't allow commenting. :(

[UPDATE: Thanks for the upvotes, now I can comment!]

2
  • I'm looking forward to your write-up. I'm playing around with the demo right now, and it's looking pretty good.
    – Eclipse
    Commented Mar 21, 2009 at 21:12
  • Josh: Thanks! Let me know if anything acts up, via the support form, I'll get back in touch via email. Or on Twitter, I recently joined (jonbho).
    – jonbho
    Commented Mar 22, 2009 at 0:05
7

The closest thing that I've seen is Codekana, although doesn't have "background syntax-highlighting" it colorizes the different flow-control structures:


(source: codekana.com)



(source: codekana.com)

  • Red for loops
  • Green for if-blocks
  • Brown for else-blocks
  • Aquamarine for switch-blocks
  • Olive for exception blocks
  • Orange for 'return'
6
  • Having the line that connects the indentation level helps too.
    – EBGreen
    Commented Mar 18, 2009 at 21:12
  • Especially since the lines are colorized based on the structure they represent.
    – Eclipse
    Commented Mar 18, 2009 at 21:13
  • implementing this sort of color scheme would be fairly trivial in Vim, I would think...
    – rmeador
    Commented Mar 18, 2009 at 21:23
  • Nice...now do it. I'm too lazy.
    – EBGreen
    Commented Mar 18, 2009 at 21:24
  • NB: It uses outlines instead of background coloring because of VS's limitations. CMS: The correct name is "Codekana". rmeadoe: A basic version of this is non-trivial. An advanced version is highly non-trivial. Chris Nava: I implemented it for VS, doing it for Eclipse must be hell.
    – jonbho
    Commented Mar 21, 2009 at 20:53
7

Coderush does structural highlighting:

alt text
(source: devexpress.com)

It quite feasible you could write your own plugin with DevExpress that achieves your exact original screen shot.

3

The current BlueJ editor does exactly what you describe:

BlueJ editor screenshot

0

The Visual Studio IDE does this already, but with a different visualization - you can expand and contract nested blocks by clicking the +/- buttons on the left margin.

2
  • Yes, but those don't give any clue as to the type of structure (whether it's an if statement, a class defintition, a catch block, etc..
    – Eclipse
    Commented Mar 18, 2009 at 21:11
  • @EBGreen - agreed. In my experience code folding allows people to write obscenely large methods and then just hide it in a fold to hide the code smell. I've encountered folds that were over 1K lines long, next to several other 1K line folds in the same method.
    – Matt
    Commented Mar 18, 2009 at 21:32
0

A nice idea. Personally, I really don't like folding editors, but this would be quite tolerable - you'd want to be able to toggle it on/off easily though. Perhaps someone has already done this for the hyper-programmable editors like vim and emacs?

0
0

I think Xcode 3 does roughly what you want, especially with Focus Follows Selection enabled. Individual blocks are highlighted as you hover over them in the sidebar.

2
  • The question mentions C#, but also C++, and doesn't really seem to focus on any language at all. Commented Mar 18, 2009 at 21:38
  • You are correct, but with the C# and Visual Studio tag I would say that MS focus is likely.
    – EBGreen
    Commented Mar 19, 2009 at 13:39
0

You should try this Addin and you will never work in visual studio without it, http://www.jetbrains.com/resharper/features/index.html

PS: I'm not affiliated with this company or product but I'm an addict using it and I can never work without it, it saves me alot of time in my coding tasks and code exploration and debugging.

0

I'm working on a Visual Studio extension inspired by this question. You can see what I have so far here:

http://lorgonblog.wordpress.com/2010/11/12/the-f-compiler-source-release-making-it-easy-to-write-cool-visual-studio-extensions/

0

There's also a free extension that at least draws the guide lines colored according to what they belong to. For instance, if guides in green and so on:
Example screenshot

It's called StructureAdornment and you can get it in the Extension Manager or from the Visual Studio Gallery.

I find it quite handy.

0

allmargins extension works for me in visual studio 2010

Tool-->Exention Manager --> search for allmargins

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.