Vim, Part I: Improved Python syntax, Blackboard color scheme
Every few months, I notice that TextMate exists and try to use it; inevitably, the requirement that I use arrow keys defeats the endeavor. It has a few features, however, that I like, most of which I've ported to vim, my primary text editor. These features are too numerous for a single post, so I'll highlight them in a series. First up: An improved Python syntax definition and my favorite color scheme.Python Syntax
The most popular Python syntax highlighting script is pretty complete, but it's missing a few things (Update: several of the improvements I made a year ago have been added to Dmitry Vasiliev's script, such as decorators, doctests, imports, etc. I've merged the two, so this is slightly less special than before). Specifically: docstrings, self
, arguments/base classes, assignment as distinct from other operators, and a few other little things. TextMate had these, so I ported them, and the results were pretty good.
Download the improved syntax file and drop it into ~/.vim/syntax
.Blackboard Color Scheme
TextMate had a color scheme that I loved: Blackboard. The colors were primaryish without being irritatingly bright or clashing; keywords, builtins, and class definitions were given appropriate prominence. I ported it to Vim. Here's what it looks like:
That example doesn't include a doctest, but they are highlighted separately in the same color as builtins.
Download the color scheme and drop it into ~/.vim/colors
, then do :colorscheme blackboard
to see the results. Pretty easy on the eyes, no?
Next in my Vim series: automatic handling of pair completion (and deletion).
July 4, 2009 at 10:10 AM
Nice post. Looking forward to the next in the series. I just switched from TextMate to Vim and I love it.
July 5, 2009 at 2:04 AM
Nice post. But what I most enjoyed was learning the meaning of the word Concinnity. Thank you.
:-)
July 6, 2009 at 12:33 PM
That's a really nice colorscheme. Thanks for sharing it.
July 10, 2009 at 7:05 AM
Thanks! I've been wanting to get "self" highlighted forever, but never bothered to learn how.
July 10, 2009 at 5:21 PM
I've ported your theme to the "original" ViM, maybe your interested in it, so here is the url
July 21, 2009 at 6:23 PM
What's that font you're using in your console? Looks pretty for coding.
July 21, 2009 at 6:24 PM
What's that font you used for your Blackboard screenshot? Looks pretty for coding.
August 21, 2009 at 7:32 PM
The little improvements in the syntax highlighting really do make a difference and I thank you for your work on this. Haven such a good looking colorscheme as a bonus... priceless.
Thanks.
October 6, 2009 at 10:38 PM
I love the blackboard theme! Nice article btw..
December 7, 2009 at 3:29 AM
hi, i love your colorscheme, but it doesn't work on ubuntu 9.10. All the keywords of python appear in yellow. Do you have any ideas about it ? Thanks
March 5, 2010 at 9:41 AM
nice post!
November 23, 2010 at 9:10 AM
Thanks for this post. The blackboard theme doesn't work for me in Ubuntu 10.10. Any ideas?
November 23, 2010 at 9:27 AM
Hmm, I have it working for me in Ubuntu 10.10. Are you using gvim or just vim in xterm or gterm? This theme is really for gvim.
March 23, 2011 at 5:20 PM
Trying your python.vim with blackboard colorscheme, self is not highlighted when followed by a period. It only highlights if folowed by itself.
March 24, 2011 at 1:19 PM
Run the command in vim or add the following line to your .gvimrc.local and the syntax highlighting should completely work:
let python_highlight_all=1
March 7, 2012 at 2:23 PM
What I most wanted out of this scripts was highlighted method names, and I don't get any. I am on a dark background with python_highlight_all set to 1 and colorscheme set to blackboard. What am I doing wrong?
February 1, 2013 at 12:20 AM
Is there any chance you know of a source for Terminal based blackboard (not gvim)?
I'm using vim through OSX Mountain Lion's terminal, and this isn't compatible, but it's gorgeous.
April 24, 2013 at 5:06 AM
Hi! Nice script I really like it, but at my computer there is one problem. When I define class in this way:
class Classname:
# this comment is orange, and all the text down untill next correct pattern or whatever
Best
May 20, 2013 at 1:25 PM
When I use this colorscheme, I get different colors than what appear in your example picture.
For example, when I type "class EventsAPI(object):", it is highlighted in green. But is orange in your example, what am I doing wrong?
My .vimrc is just setting the colorscheme and then 'syntax on'.
June 12, 2013 at 2:19 PM
I have an issue with your script. It doesn't highlight the params and function names. I'm using ubuntu.
Can you post a full vimrc settings?
August 27, 2013 at 9:09 AM
Ian, thanks for the great work!
I've made some changes:
- fixed the issues with class definitions that were mentioned in the post from April 24, 2013 at 5:06 AM and some other issues from the comments here
- made separate match group for "self"
- added highlighting of named parameters in function calls, like in "x = func(PAR=y)", PAR will be highlighted. This is not very well tested, but it works for me.
Here is the patch (git format):
http://pastebin.com/YwXHdwnT
Have fun with it!
June 29, 2015 at 9:05 AM
Like the colors but white it desturbing.
I used this one for normal text.:-)
#5fcfcf
November 18, 2016 at 1:27 AM
Never gonna give up
December 23, 2017 at 4:54 PM
Your beautiful color scheme is gone from googlecode! :( It's not there anymore.