I’m pretty picky when it comes to how I look at my code.  My tastes might even be a bit unique — I like things really small, colorful (earth-toned rainbow), and highly differentiated.  There are so many things that I value in a scheme that I decided to try and collect them here.  I use Vim, but this article should be editor-agnostic.  Have a look at my recent version of Adobe color scheme for Vim that aims to satisfy the criteria of this article.

It’s worth mentioning that some people hate syntax highlighting, and claim that it is distracting or gives them a headache.  My guess is that most of these people have never had the chance to work with a subtle-yet-attractive color scheme.  It’s a pretty well-accepted fact syntax highlighting is useful for catching typos and various bugs.  It takes a bit of training to notice when something highlights in an unexpected way, or doesn’t highlight when it should, but an eye for it can really improve your code quality.

Philosophy

  • Nothing should be bold unless it’s very important and should stand out above all other things. Functions/classes are good for this.  (I’m actually using a font/size now that does not support bold.)
  • Colors should be easy on eyes to stare at for many hours.  The background should be extremely comfortable for your eyes, so not white, and probably not even black.
  • Todos should stand out just a little (underline looks nice).
  • Inline comments should stand out less than anything else.
  • Code “commented out” should be nearly invisible.
  • But real in-code documentation should have strong emphasis and beauty.
  • Everything should be differentiated, including identifiers, keywords, 3-4 types of comments, strings, types, constants, conditionals, control structures, and more.
  • Strings should be a nice color since much documentation should exist in source code as strings (think “”" comments in python or /** in java).
  • Normal text should be colored either black or white so it is obvious if something is not recognized syntax.
  • No two used colors should be highly similar.  Beauty is secondary to contrast.
  • Each language will have some special syntaxes that need specific attention.  E.g., py, pl, sh, html, vim, rst, moin, mail, etc.  It’s helpful to have a variety of file types hanging around and fire up your editor on each of them for the scheme you’re developing/modifying.
  • The scheme should look nearly identical whether being used in an xterm or in a GUI.  E.g., looks the same in vim as gvim.
  • Really needs to support 256-colors.  There are just too many different highlights to try and cover in 16 colors.

I’ve described the different types of comments in this related post.

Have a look at the repository of color schemes for vim.  There is also a nice screencapture of the repository.

adobe2

Download my pythoncomments patch to enable python.vim syntax recognizer (for v2.6.3, maybe already part of your Vim installation) to make use of the various features of this article.  The patch is not necessary, but helps with some comment highlighting.

Tags: , ,

One Response to “Editor Color Scheme Philosophy”

  1. Yang says:

    It seems the adobe.vim you put in http://www.vim.org was not complete, especially for vim under command line: lots of colors has not been configured for ctermfg.

    Best regards.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>