March 2010
M T W T F S S
« Feb    
1234567
891011121314
15161718192021
22232425262728
293031  
96

Categories

Archives

Managing WordPress Posts with vim

I’m a vim guy through and through. Always have been. But I’m no zealot. I say you use the tool that does the job. So for example, I’ve used xemacs on occasion, and it definitely has its strengths. But for day to day I’ve always come back to using vim. So when I setup this blog, I knew early on that if I was going to post at any sort of meaningful frequency, I would have to figure out how to do it through vim. Additionally I’ve grown accustom to mark up languages such as markdown & textile, so I knew I’d want to mix this capability in to both my blog & vim, as well.

NOTE: refer to these Wikipedia pages if you’re unfamiliar with vim, xemacs, markdown or textile.

Preliminary Step

Before we get started, make sure that your blog is configured to accept XML-RPC. This is a remote procedure call mechanism that allows external tools to submit posts to your blog. The option is underneath the site admin section of Wordpress. You can get to the option under Settings –> Writing. The option looks like this:

XML-RPC Option

XML-RPC Option

Getting Started

After googling a bit I came across a plugin for vim called Blogit. The main developers page for Blogit is here, while the primary vim.org plugin page is here. The latest version at the time of this article was 1.3. Installation couldn’t have been simpler.

Installation

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# get into vim's dot directory
% cd ~/.vim
 
# download Blogit
% wget http://symlink.me/attachments/download/16/blogit-1.3.tar.bz2
 
# install blogit
% tar jxvf blogit-1.3.tar.bz2
 
# ~/.vim directory should look similar to this
% tree -A 
.
└── plugin
    ├── blogit.vim
    └── mock_vim.py
 
1 directory, 2 files

Configuration

The only other thing you need to do to setup the Blogit plugin is to create the following file: ~/.vim/plugin/passwords.vim. In it you’ll need to add 3 pieces of information about your blog. A username & password along with the URL to your blog’s xmlrpc.php file. Here’s an example:

1
2
3
4
" login credentials for blog
let blogit_username='user1'
let blogit_password='password1'
let blogit_url='http://www.lamolabs.org/blog/xmlrpc.php'

Blogit’s Interface

After firing up vim, you can get a list of all the Blogit commands with the vim command Blogit help, like so:

blogit help

blogit help

You should get a split window in vim with the list of Blogit’s commands. BTW, most of these commands should be pretty self explanatory.

blogit commands

blogit commands

To get a list of all the posts available, run the command “Blogit ls”.

list of posts

list posts command

Again you’ll be presented with a list of all your blog posts, in a split window inside of vim.

list of posts

list of posts

You can use your arrow keys to move the cursor up and down through the list of posts. Additionally you can open posts up by placing the cursor on one, and pressing the enter key. In the example below, I’ve selected post#: 2362. Hitting return results in this particular post being opened up in vim’s primary window.

scrollable window

scrollable window

Here’s the results of post#: 2362 being opened.

view selected post

view selected post

Running the command “Blogit ls” again brings up the list of all the existing posts.

scroll another post

scroll another post

Mark Up Languages

As I mentioned previously I’m a big fan of mark up languages such as markdown & textile. For no other reason, than I just prefer it, I chose to use Textile. To enable Textile support within Wordpress I installed the plugin Textile2. If you check out the Wordpress Plugins Directory there appears to be a number of suitable textile plugins. Even though this particular plugin hadn’t been updated for sometime it has worked flawlessly for 8+ months under the latest versions of Wordpress (i.e. 2.7 up to 2.8.4+).

Here’s a screenshot of Textile2’s configuration pane in Wordpress:

Textile2 Config

Textile2 Config

Also to close one final loop, I installed the Wordpress plugin WP markItUp!, on the off chance that I might actually use the web based editor for tweaking a post here or there. Installing this plugin basically switches the default Wordpress editor out for one that can handle an assortment of mark up languages, Textile being one of them. Here’s a screenshot of post#: 2362.

WP markItUp! Editor Example

WP markItUp! Editor Example

Here’s how I configured the WP markItUp! plugin:

WP markItUp! Config

WP markItUp! Config

Conclusions

I’ve been using this setup for several months and it has just worked. I highly suggest you check it out if you maintain your own blog in Wordpress and you too prefer working in vim.

NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>