The problem that makes this question so hard is that specific solutions very quickly become obsolete. The day the solution is posted the version of vim
or python
is updated or links change. The steps provided by @mark-colon are fantastic but oriented for vim-7.
Generic instructions:
vim
and python
need to be in sync on many different levels:
Both need to be 32bit or 64bit
Vim needs to find a specific python dll version. It depends on who compiled your version of gvim. For example, gvim-8.1.x may use python3.6 or python3.7 and the exact version is required! Sometimes you can use:
gvim --version
to see what specific dll is being searched by vim at launch, otherwise you need to find out from where you downloaded gvim. This is the version ofpython
that you must search the internet and install on your system. (Alternatively, if the version of python is more important to you than the version of vim, you can try to find a version of vim that was compiled for python but this will be harder to find.)Make sure the directory that holds the python dll needs to be on the %PATH% environment variable. (Note: some just copying the python dll to the $VIM folder to get things working only works in the short term. You don't have all the necessary python libraries that are often assumed to be available.)
Finally, verify with ex command
:python2 print("hello")
or:python3 print("hello")
depending on what version of python you wanted.
Specific links (if you must):
Note: these will all soon be out of date, but the following are some links to various compiled versions of gvim and python that could work together:
For gvim-8.1.x
& python-3.7.x
or python-2.7.x
as of 2018-08:
For gvim-8.1.x
& python-3.6.x
or python-2.7.x
as of 2018-08:
For gvim-7.4.x
& python-3.5.x
or python-2.7.x
as of 2018-08: