Using Python plugins with Vim on 64-bit Windows 7

Among the most most important features of Vim, the popular vi-compatible editor, are the plugins used to extend its functionality. Most Vim plugins are written in Vimscript, Vim’s built-in scripting language. Support was added in Vim 7 for plugins also written in Python, Ruby, and Perl. I wanted to use a Vim plugin written in Python on my 64-bit Windows 7 system and was surprised by how difficult it was.

Although Vim versions later than 7 can support plugins written in other languages, that support has to be compiled into the copy of Vim you use. One way you can tell is to display version information by using the version command:

:version

It will display a whole screen of information about your Vim version and what options were used when it was compiled. If your version has Python support then you should see +python,+python3, +python/dyn, or +python3/dyn. If you don’t, or if you see those options with a minus sign instead of plus (such as -python), then Python plugins aren’t enabled. Another way to test this is by using the has command to try options individually, such as:

:echo has('python')

You should see 1 if Python is enabled, 0 if it isn’t.

The version of Vim I had installed was the standard Windows version available at vim.org. Suprisingly, this version does not appear to have Python support compiled in. So if you want support for Python plugins, the only options are to compile your own version or use a different distribution.

I decided to use tuxproject.de.nyud.net/projects/vim, which has the most current version of Vim with plugin support enabled.

(Another option would be to use the 64-bit Vim at code.google.com/p/vim-win3264, but that version hasn’t been updated in quite a while.)

I have a special directory that I use for portable applications. After uninstalling my existing version of Vim, I extracted the new version I downloaded into that directory. (The Vim directory must be named vim73.)

That was about all it took to setup my new version of Vim. My existing _vimrc was picked up automatically. I did need to manually edit my batch file (vi.bat) pointing to vim.exe.

Vim comes with an installer named install.exe which you can use to add Vim to the start menu, create a desktop icon, and perform a few other installation functions. If you want to run it, you’ll find it easier if you first change the name to something other than install.exe (such as i.exe). Windows assumes files named install are installers and treats them differently from other programs, which really isn’t what you want here.

At this point, I had a version of Vim which could support Python plugins. But I had one additional problem. I had a 64-bit version of Python installed, which 32-bit Vim couldn’t see. I solved this by uninstalling my 64-bit version of Python and installing the 32-bit version.

By following these steps, I ended up with a version of Vim that works with Python plugins. You can verify this by trying the python command within Vim:

:python print('Hello world')

2 comments on “Using Python plugins with Vim on 64-bit Windows 7

  • Hey, thanks for recommending my Vim build. :-)

    Kind regards!

  • Tomas Volf wrote:

    Honestly, I really think that simplest solution is to compile Vim by yourself, surprisingly easy to do. And you can compile in both python2 and python3. And have 64bit version. Well, at least this was what I did.

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2007-2024 by Matthew Reed, all rights reserved.
ContactPrivacy Policy