Writing WordPress Articles with Code Examples in Vim using Markdown

Lately, I’v been thinking about writing blog articles in Vim and finally, I found a solution! But before we get to the how to part of the article, let my first outline some of the reasons I wanted to use Vim for article writing instead of WordPress online text editor.

  • I’ve been using Vim as my primary coding editor for past five months and had configured everything so I’m pretty comfortable programming in it.
  • It is far easier and faster to write an article in vim using markdown for simple formatting and type one command for the article to be uploaded on my blog than to open up administration of my blog and write it there.
  • When writing code examples, you have two options:
    1. Use WordPress text editor
    2. Write the code in your programming editor locally and copy the code to the article all the time
  • Both of these options suck pretty hard and I think I don’t need to explain why. Now, when using vim for writing articles, I can just switch filetype of the file I’m writing and then I can type my code comfortably and with all the plugins directly in vim.

Given enough reasons, let’s look how to setup vim for writing WordPress blog posts with code examples!

Installation part

What we need and will install

You can use whatever way of installing Vim Markdown and VimRepress but I use Vundle (because it is so good!).

After we had installed all the requirements, we need to configure VimRepress to be able to access our blog.

VimRepress configuration

Everything we need to do is to create a file called ‘.vimpressrc’ in our home folder (~/.) and put this content into it:

blog_url = http://ourblog.com
username = admin
password = 12345 (or can be left blank, plugin will prompt for it)

That’s it! Nothing more.
Now, let’s look at some of the useful VimRepress Vim commands.

VimRepress Command Examples

These commands are copied from the official VimRepress plugin page.

:BlogList             -  List 30 recent posts. 
:BlogList page        -  List 30 recent pages. 
:BlogList post 100    -  List 100 recent posts.

:BlogNew post         -  Write an new post. 
:BlogNew page         -  Write an new page. 

:BlogSave             -  Save (defautely published.) 
:BlogSave draft       -  Save as draft. 

:BlogPreview local    -  Preview page/post locally in your browser. 
:BlogPreview publish  -  Same as `:BlogSave publish' with brower opened. 

:BlogOpen 679 
:BlogOpen http://your-first-blog.com/archives/679 
:BlogOpen http://your-second-blog.com/?p=679 
:BlogOpen http://your-third-blog.com/with-your-custom-permalink

I hope you’ll enjoy using your super powerfully-configured Vim editor for writing your blog posts.

Have a nice day.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s