Running Sparkup Vim Plug-in on Arch Linux

The sparkup plugin for vim lets you write HTML markup faster by Zen Coding, in which you write short code, resembling CSS selectors, which is then expanded to HTML by the editor. For example, writing


would give you:

<div id="nav">
    <ul id="menu">
        <li class="item"></li>
        <li class="item"></li>
        <li class="item"></li>

This is obviously extremely useful, as it saves a lot of typing. However, I encountered a bit of trouble using this plugin on my laptop, which runs on Arch Linux. It’s easily solved though.

The problem is that the plugin is written in python 2, which is an older version of python, however still the most widely used, because most systems with python installed have python 2. But, because one of the key points of Arch Linux is to have up-to-date software, the default python is python 3, so typing “python” in Arch Linux would run python 3, whereas the same command on another system, like Debian, would run python 2 and the sparkup plugin is not compatible with python 3, so you get lovely errors like :call <SNR>63_Sparkup() shell returned 1.

Of course python 2 is still available in Arch Linux, in a package cleverly named python2, so you just need to pacman -S python2 to get it. Now, python runs your script with python 3 and python2 runs your code with python 2, and you just need to do two things:

  1. Find the line in sparkup.vim where python is called and change it to python2
  2. change the shebang line in to use python2 instead of python, i.e. #!/usr/bin/env python2

and then it should all work fine! 🙂