May 13, 2013

The VIM "Zen Coding" plugin

This plugin is either buggy or very hard to figure out. I fooled with it for a while, then abandoned it.

One big issue with this plugin is that some features seem only to work with gvim, which is not what I choose to use. In particular features that expect you to select a group of lines and do something to them.

This plugin can do many nice things if you find yourself composing html at the keyboard a lot (as I do). One is to take an unformated list of things and wrap it with "ul" and "li" tags given a few keystrokes. Another is to take a URL and wrap it with the "a href" tags to make it a link. And it can do much more.

Note that zencoding is a project that targets other editors (like TextMate for Mac, which I hear lots about), and the vim plugin is "unofficial". Zen coding has apparently transformed into something called "Emmet", but vim support for Emmet is also unofficial, and it is hard to tell which to choose

By default the Control-Y triggers the plugin. I find (as for all of the Vim plugins) that the documentation just kind of suggests what can be done, and you have to fiddle around to figure out how things work. Keep an eye on the status line at the bottom of the screen.

Also note that Control-Y followed by a comma is the thing to do in several cases, and this is impossible to read on some of the tutorial screens.

You can convert "b" to a balanced set of tags using Control-Y comma. If you do it while in insert mode, you can just keep typing what goes inside. If you do it outside of insert mode, you get a set of tags and don't enter insert mode. Do this with the cursor at the end of the word you want to make a tag out of.

The Control-Y and "a" to anchorize a URL takes forever because it is actually accessing the URL to get something to put inside the tags!! Be patient. I think this is a bad idea. In particular if you choose to anchorize something that is not a valid URL or a host that does not exist, this seems to get locked up forever (or until you type control-C). This does work in vi and gvim both.


Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]