It is possible to post blog entries to Drupal using VIM. The only caveat is that VIM should have the python extensions compiled into it. Also, Drupal should have the blogapi enabled to allow posts to be submitted or read via XMLRPC. The following code is put in the .vimrc file:
python << EOF strUserName = 'me' strPassword = 'bigsecret' strDrupal = 'http://my_server.com' def PostBlog(): import xmlrpclib import re # # If first line contains a blog entry ID then edit existing post, # otherwise write a new one. # nFirstLine = 0 strID = vim.current.buffer[0] if not re.match( '^\d+\$', strID): strID = '' else: nFirstLine = 1 strTitle = vim.current.buffer[nFirstLine] strText = "\n".join( vim.current.buffer[nFirstLine+1:]) oDrupal = xmlrpclib.ServerProxy( strDrupal + '/xmlrpc.php') oPost = { 'title': strTitle, 'description': strText} if strID == '': strID = oDrupal.metaWeblog.newPost( '', strUserName, strPassword, oPost, 1) else: bSuccess = oDrupal.metaWeblog.editPost( strID, strUserName, strPassword, oPost, 1) print "Posted entry %s" % strID # # Don't intend to write posts to disk so unmodify the buffer and # allow easy quit from VIM. # vim.command( 'set nomodified') def ReadBlog( strID = None): import xmlrpclib oDrupal = xmlrpclib.ServerProxy( strDrupal + '/xmlrpc.php') if strID: oBlog = oDrupal.metaWeblog.getPost( strID, strUserName, strPassword) else: oBlogs = oDrupal.metaWeblog.getRecentPosts( '', strUserName, strPassword, 1) oBlog = oBlogs[0] strID = oBlog['postid'] vim.current.buffer[:] = [] vim.current.buffer[0] = strID vim.current.buffer.append( oBlog['title']) vim.current.buffer.append( '') for strLine in oBlog['description'].split('\n'): vim.current.buffer.append( strLine) EOF
To use this, type a blog entry into a buffer. The first line should be the title of the posting, the remaining lines are the body. For example:
Thoughts from a Blogger I am a rampant blogger. Heaven help me.
Then, from the VIM command line execute:
:py PostBlog()
The ID for the new posting will be displayed. A posting can be edited using:
:py ReadBlog( <ID>) e.g. :py ReadBlog( '451')
to read the posting and
:py PostBlog()
to post it again after editing it.
You can also edit the most recent posting by entering:
:py ReadBlog()
This could be expanded a lot more if I had the time, for example:
- Show list of previous posts to open and edit
- Map ':w' to post the blog entry
- Use pure VIM code if that supports xmlrpc (?)


I use the MozEX extension to Firefox. Among other things, it can open up the contents of any textarea in VIM.
-Neil http://delocalizedham.com/