Sunday, December 20, 2009

entire file view of matching searches.

So I've been using IntelliJ a lot for my Java and groovy development lately and noticed a cool feature of its editor recently. When you do a search, a little tick mark is made along the area of the scroll bar for each match to your search. This is kinda cool as it gives you a general idea of how many matches there are in the file, and a general sense of where they are.

So I was thinking. I wanna do this in Vim. How? Well, if you have +signs support built could do as I did. This is what I got toward:

This works in the same general way: the green hilighted area essentially corresponds to the shows you what part of the whole file you are looking at right now. The little ticks show you where the other matches are in your file.

Anyway, I think its generally a cool idea. I've made a plugin that shows this stuff on the side whenever you have the 'hls' setting on. Whenever you move around the file it automatically updates so its generally correct. Still some bugs, but I'm working on it. You can try it out yourself from github.

General conclusions/thoughts:
  • vim-unit continues to rock. I'm almost to the point of considering going all ruby or all python for serious vim scripting though.
  • It sure would be nice if there were events you could subscribe to when your location changed in Vim. There is something for window sizes changing...but w/o this you're pretty much stuck using the CursorHold type cludges - which just feel like cludges unless you get your handler code really efficient (quit early, do as little as possible, set udpatetime high).
  • I wish MacVim supported images for +signs! I've checked out the MacVim project from git. If I get some free holiday time I'll definitely look into making images to get a more IntelliJ like result -- although I suppose the solution I have now is good in that it'd work on the console. Still.
  • Wouldn't it be sweet if you could have a left gutter +signs support as well as right gutter? IntelliJ really can tell you a lot by making use of them.
  • I'm thinking this +signs thing for code coverage tools would be kinda nice...have to look into that at some point...