Laugh at me if you wish to, or call it heights of craziness.

I wouldn’t be surprised,since most of my classmates (and non-classmates too)  find my addiction for writing well-highlighted notes in >= 3 colors ridiculously amusing anyways.But then, old habits die hard, and as I find myself  using Vim  these days for everything I can, I miss the good old luxury of color and personalization of notes that pen and paper provide. I could switch to a normal word-processor and use the M$ style WYSIWYG formatting – but that would be like tasting bitter-gourd after fig ice-cream 😉

So I tried to see if I could do some quick job to make those additions to Vim today- keeping  a couple of my notebooks with me  to see the requirements. This is what I could get –


The Plugin in Action - Note the template with User Details

Here is what  I (and hopefully any other average user) would expect from a note-taking plug-in –

  1. I write in bullet points – so all stuff should go with bullets.
  2. The ‘interface’ has to be natural and intuitive – it shouldn’t require me to explicitly choose something from a menu or add meta-data like tags or commands – or else I could anyways use Word in the former case and Latex in the latter. It should be as natural and transparent a process for me as is switching pens while writing.
  3. I should have my insights and ‘Aha!’ moments captured easily and automatically.                                                                                              Random Note 1: You wont know this unless you draw smilies between lines in your notes for the silliest of reasons like stupid mortals (me)  or Goddesses (Ramya K V, Ruta Desai, Rishita Anubhai – the list is long) do.
  4. Sections and Headings should be automatic and natural – no tags, no HTML or Latex like business.

(1) and (3) were obviously  kid’s play. (2) was what seemed to be the only non-trivial part of this exercise – but that is before I tried it. When I finally got a workable solution, it was ridiculously trivial. Vim allows the user to define syntax regions – with start,end and patterns to skip – and they are deceptively simple. So I defined my ‘blue notes’ region to be that which starts with a ‘ ->’  and ends at a newline (logical not virtual). Similarly for ‘red-notes’ (really important stuff)   and ‘=>’ bullets.

This is fairly ‘natural’ and intuitive to me as a user, but it isn’t what I wanted when I started out – mainly because it confines me to use specific bullets when I want a color. What I wanted was something like ‘modes’ , for each colour and key-bindings to switch between these modes.

So ideally I would have had something like ‘toggle F1 to keep black pen off/on’ and such. But my study of Vim’s highlighting features tells me it deals with colours only in terms of  ‘groups’ which are specified again with regex-es and  patterns – so I couldnt get my ‘modes’ idea to work here. If you have any insights for  achieving that, I would be more than glad to hear.

A lesson I learnt  – its better to go for ‘syn region’ rather than ‘syn match’ whenever you can, unless you are some Vim reg-ex (its slightly different from normal reg-ex) God. I spent quite some time trying out syn match and getting buggy results  before I realized how it horribly trivial it was to do the same thing with regions. And due to this design, (4) turned out to be easy too – no bullet at the beginning of a line implies a new section, so it highlights and shades that as a heading. Finally I added a couple of  lines for abbreviating horizontal separators and  some   ‘syn match’ rules from the syntax file for Vim’s in-built  help to colorize those.

Random Note 2: The help.vim that comes in /usr/share/vim/syntax is an excellent place for some really clever syntax constructs, since the in-built help has more detailed syntax than any programming language one normally encounters.

I use the user’s git-config to find the name and email ID (‘inspired‘ from here)  and add a small template for each .notes file.  I am happy to note that I can use this stuff not only for easy note-taking, but also for web-log updation if needed, thanks to  TOhtml and for effortlessly cross-referencing my notes, thanks to Vim’s awesome ‘gf ‘ command. The plugin code is available at my github account if  the reader (whose existence and whose having read all the crap till here is a big and mostly incorrect assumption) wants to try.

git clone git://

It only works in gvim for now – since I am too lazy to add cterm attributes for portability. Developing for Vim to automate/simplify routine tasks is fun and I hope to add a post on a veTTi <sarcasm>project</sarcasm> here soon. 🙂