[personal profile] archerships

Original: craschworks - comments

When reading new code, especially code in a language I’m unfamiliar with, I sometimes have to translate each symbol/method very methodically in order to understand what the code is trying to do. Often, I’ll put my notes in the code as comments. While this helps me, this can make the code more bulky and difficult to read for those who are familiar with the code/language. Ideally, I’d like a vim plugin in which I can keep notes on a file, without actually changing it. Anyone know of such a plugin?

Date: 2009-11-14 09:34 am (UTC)
From: [identity profile] parakleta.livejournal.com
Having a separate file for you notes and using scrollbind to keep them together is about the best I can suggest without things getting tricky. I'm not aware of any plugin that will do it automatically.

I can't find any documentation on the hooks vimdiff uses to do its thing, but it'd be the avenue to pursue if your annotations will be longer than the source file, since it can inject blank lines visually in the original without changing it, and you can do tricks with fold and whatnot. I had a quick look to see if I could come up with some way to trick it into doing something useful, but I don't think it'll be a simple solution (mainly generating the file... with a patch file that converts the original file into the notated version (or just the notes) it's pretty easy to get vim to display it in a useful way, but I can't figure out a good way to make the patch file).

Another alternative is just to make sure your annotations are always delimited by some special tokens and then have a sed script or something strip them out when you distribute the files.

Date: 2009-11-14 10:06 am (UTC)
From: [identity profile] crasch.livejournal.com
Thanks for the suggestions! I was not aware of scrollbind.