10 September 2013

Blogging with Markdown from Vim

If you're a programmer, you probably spend a lot of time in a text editor. You may also have spent a lot of time choosing your text editor. You've probably also spent a lot of time learning and perfecting your use of that text editor. And if your text editor is Vim, you probably hate entering text anywhere other than your text editor.

If you're into writing rich content, you probably spend a lot of time using content markup tools. If you're a programmer, you probably prefer using some kind of markup language over a GUI. If you've been exposed to Markdown, you probably don't want to consider anything else.

It follows logically that as a Vim-using, content writing programmer who likes Markdown, I would like to write my blog entries using the marvelous Markdown syntax in the comfort of my powerful Vim editor. To the average blogger, this may seem like a ridiculous desire, but to a guy like me, once I discovered this was possible, I wouldn't have it any other way.

Initially, I set out to develop a Vim plugin that would allow me to post to my Blogger account. Since Blogger is a Google product, I wasn't surprised to find that my expectation that there would be a Blogger API was correct. Paired with my moderate Vim plugin skill, this was a promising starting point for my plugin.

Even though I didn't think anyone had done this before, I decided to search for an existing plugin that could at least act as a foundation. To my surprise, I found Blogger.vim, which, at first glance, covered all of my needs out of the box. It provides a way to list existing posts and write new posts using Markdown (which gets converted to HTML). It even has an automatic Gist option where code blocks longer than 5 lines are automatically uploaded as a Gist with your connected GitHub account. (This was a feature I had thought about a long time ago; I was pleasantly surprised to see that someone has already done it!)

There were a few areas that I found the plugin was lacking or made me uncomfortable, however.

First, there is no way to apply labels (or tags) to posts. While a fairly minor grievance, it would be nice to be able to manage every aspect of content creation without using a web GUI.

Second, it doesn't provide a way to list draft posts. I'm probably never going to write a blog post in one sitting, so I need a way to continue editing an existing draft. The plugin does have a way to create drafts, but after you've quit Vim, you won't be able to get back to it.

Finally, it uses plain-text authentication in your ~/.vimrc file. While this keeps the set up process simpler, an important fact is that my Blogger account is the same as my Google account. I don't want my most important password visible to all who care to browse my Vim configuration. It would be preferable for the plugin to establish an OAuth connection (or something similar) that only has access to the Blogger features I allow.

For these reasons, I decided to stick to my initial plan and develop the plugin on my own. I'll follow up with another post once I get around to doing that.

No comments: