Imagining vim Macro That Makes Markdown Image Code

by Mike Levin

Wednesday, May 18, 2022

The time has come to cast a new vim-spell so powerful, it boggles.

The single most common tedious task I need to do these days in my new web publishing system based on Github’s Github Pages Jekyll static site generator is the creating of image tags from an already keyword filename such as:


First off, it just make so much sense to keyword an image at this point that it’s hard to believe that web publishing software doesn’t somehow enforce it early in the publishing process. I mean really why not bind the keywords to the image in the filename and forego some tedious and convoluted later image keywording process? To not use the keywords you’re targeting and intend to bring traffic in on when naming the file is just stupid.

Okay, so we’ve got a keyworded filename. What next?

The markdown syntax for creating an image is:

![Alternative text for web accessability](path/to/image.png)

Okay, nice. I can show markdown with markdown. I didn’t expect it to work so easily with markdown fenced code blocks (fencing). I expected to have to neutralize or escape characters with backslashing. This is much better. Yay! Now let’s proceed.

We’ve already got a keyworded image. The trick is just to get it into its respective locations. I like using proper-case for the web accessible alt-text area for the visually impaired. This also happens to be good for search engines. It is the equivalent of tagging images for machine learning. So if you’re not using alt-text to tag your images for search, it’s about as stupid as not using keywords to name your files.

Lack of alt-text on a non-keyworded-filename.jpg is doubly stupid. Or maybe that’s stupid-squared? Anyhow, the rest is vim.

You are using vim as your text-editor, right? Any self-respecting coder, programmer, seo, journaler, writer, sysadmin, devops or otherwise Information Age professional is, right? Otherwise you’ve put your gonads in Microsoft’s hands (VSCode, right, right, am I right?).