Slippery Snippets
Tuesday, July 25, 2006
  Tag highlighting As mentioned in a previous post I was thinking of adding tag highlighting as a fancy new feature. This was requested by a user who cited the lack of it as the one remaining reason for him not to switch away from imaps.vim. I looked into how imaps does it (boy, is the version on way out of date) and was impressed. I had a good think about how to add it into snippetsEmu and came up against some problems. When imaps highlights a tag it does so by using visual mode. Hitting any key will delete the tag and start insert mode. This does not work so well with the extra stuff SnEmu does. Deleting the whole tag will break the name replacement function and command execution. The best way would involve deleting any variable name but this would require quite a rewrite of the internals. Currently the decision of whether the user has changed a tag's value requires the presence of the name and the start and end markers.

Basically it's non-triv but I'll keep look into what's required.

I'm also going to work on reintroducing default values. I had decided that using tag names would work just as well but then thought up some examples for when it wouldn't. The simplest would be a function call commonly requiring 'Null' as some of its arguments. Having several tags named 'Null' would be useless if you wanted to change the value of just one of them.

Not sure the best way to do this. I'd also like to have auto-executing tags; useful for adding in dates or similar. This can be done at the moment using an empty tag with a command but does require the user to tab through them before the command is executed.

Thoughts and comments welcome as usual. 
  Bug fix: TextMate mode now works in Linux The new TextMate mode was not working properly under linux due to some strange behaviour with expand('<cword>'). The new version (uploaded) uses a different search mechanism so all should be better. Bug reports to the usual address.

Could anyone under *nix environments try a little test for me? Open Vim, go to insert and type: AWORD<c-r>=expand('<cword>')<cr>. That is: type AWORD, hit ctrl-r, '=' and 'expand('<cword>')'. Under Windows this will insert AWORD after the first AWORD. Under Linux it does not. Post what you get along with your vim version and environment in the comments. Cheers. 
Monday, July 17, 2006
  Ideas for new features I've been gathering together a collection of possible new features and changes which I'll post here for others to add to in the comments. Please let me know what you thing of the new ideas as well.

I'm also considering making the TextMate mode the default choice. Thoughts on that as well please.

Thursday, July 13, 2006
  Documentation One often mentioned problem with the plugin is the documentation. 
It is sad to say that the documentation has changed in a similar style 
to the plugin itself. I've had to make numerous 'bug fixes' and the 
additional features are poorly described. Inspired by Panos's initial 
draft I've started to create a proper piece of help to include with the 
downloads. If I get time I'll finish it off this weekend. 

I'd also like to thank Panos for the lovely logo sported underneath the 
link on the right. He's knocked up a 'powered by' style image as well:  

Very nice.

Anyway: new docs are coming and I'm trying to gather together some examples for different languages as well. If you have any you'd like to share then post them in the comments. Mention what your start and end tags are as well. I'm tempted to remove the customability of start and end tags in order to make sharing easier. I was thinking of '<{' and '}>' as the new standard but let me know your thoughts on that as well. 
Wednesday, July 12, 2006
  Blast off! I've discovered that the person hogging my usual username on Blogger was in fact me and so after rooting around the back corners of my memory I produced a password and decided  to use this fantastic free service to start up a development blog about my Vim plugin: snippetsEmu.

The script has been through several iterations so I'll use this first post to record its history.

My initial encounter with the OS X editor TextMate was (no doubt like a lot of people) through the magical Rails videos. Not to distract from the DSL goodness of Rails but one reason it looked so damn easy to use was the fantastical editor used to construct the beautiful code. Sadly I had given away my iMac as I was moving houses too often (a very generous gift for my brother) and so could not join in the fun.

Thankfully my work required that I make regular use of the One True Editor and I had just discovered its built in scripting functionality. Being a fan of Python and having started on the long, dark journey towards mastery of Word macros, the lure of some new scripting treasure was too great and so I set out to make for myself that which others already had.

Not one to stand on the shoulders of giants (and too lazy to thoroughly Google about) I set about replicating the TextMate functionality from scratch. My initial attempt used the builtin iabbr command to add a load of @'s into the buffer and some simple searches to jump around between them. Pleased with this I promptly documented it on the Rails wiki, where it still stands today.

To be honest, this initial attempt was crap. Had I discovered the imaps plugin for Vim then I no doubt would have used that instead and been happy. But thankfully I discovered the MacroMates post on the power of snippets which showed me just what extra work was required. An initial release soon followed which added variable replacement. A couple of weeks later, based on a suggestion from Salman I added a new version which allowed users to define their own start and end tags. I also added in the idea of default values. I never really liked this idea as I personally used the tag's name as a default value but, ever eager to please, I added it in.

A few bug fixes later I uploaded version 0.3. This added the idea of command execution. A couple more bug releases and a change in the way commands were defined and development slowed up.

Six months later I uploaded version 0.5. I'd seen a bit more of TextMate in action and I'd changed some of my ideas about how things should work. Default values were removed (these make sense in TextMate but only because the tags used there are not displayed on screen) and the new TextMate compatibility mode was added. Snippets no longer expand by default; the user is required to hit Tab before the magic happens. More bug fixes and we're up to date.

July 2006 / August 2006 / September 2006 / October 2006 / November 2006 / December 2006 / March 2007 / April 2007 / May 2007 / July 2007 / September 2007 / February 2008 / June 2009 / December 2010 /

Powered by Blogger

Subscribe to
Posts [Atom]