Blogging with Vim
In the face of blogging clients, xml-rpc servers, blogging APIs and tons of
other kludge, here is how I use vim and svn to post on my pyblosxom based blog.
For pyblosxom a post is a text
file placed in a predetermined directory, so my bloggin process looks like:
1. create a file
2. commit to svn
3. check-out from svn into the right place on the server
Post templating and creation
The first problem I had to solve was the base skeleton of a post, which I was used to copy manually all the times from an older post. This was easy to solve, I just had to tell vim to load a template whenever I edited certain files, and ended up creating an alias for it:alias blog='vim "+0r ~/.blog/post.tmpl"'Unfortunately that appends the template to a file even when it's not a new post, so I had to turn that into a bash script and test for the file changing the vim command accordingly. You can download the script here. There are a few extra goodies in there, like checks for a sane filename (no punctuation!) and a vim command to load the correct filetype in order to get syntax highlighting right. Also, I define a BLOG directory and an extension, which means I can now simply do blog vimBlogging and it doesn't matter where I am, a file will be created in the right place with the right ext.
Time permitting I'd like to add bash_completation support to it so when you do blog
Committing to SVN
Aside from this post and blogging, is you use Vim and SVN/CVS/SVK do yourself a favor and get this plugin, rarely something has improved my productivity so much. Once it's setup you can browse the log, diff files and another tons of neat things all from vim. The first thing I got myself was a shortcut to commit to svn:nmap \postNow whenever I type \post a nice buffer will be open where I can input my commit message. Saving will perform the actual commit. The plugin is pretty much straightforward to setup and use, there are some extra features you can enable like versioning info printed on the status bar, just read the doc files coming with itVCSCommit
In case you wanted to do more customizations and make sure nothing is loaded if the plugin isn't, there's some more work to do. In the first place you cant just put the code in your .vimrc like we've done so far: plugins are loaded after .vimrc and so you cant test for 'em. The trick is to create a function and then use an autocommand like this:
function VCSIfLoaded()
if exists('g:loaded_VCSCommand')
let g:VCSCommandEnableBufferSetup=1
nmap \post VCSCommit
endif
endfunction
au VimEnter * :call VCSIfLoaded()
Thanks to the guys on #vim@freenode.net for all the help in figuring out the above.