How to enable Python support in gVim on Windows?

前端 未结 13 1905
灰色年华
灰色年华 2020-12-13 08:47

I\'m trying to get Python support in gVim on Windows. Is there a way to accomplish that?

I\'m using:

  • Windows XP SP3
  • gVim v. 7.3
  • Pytho
相关标签:
13条回答
  • 2020-12-13 09:09

    Add following scripts to your .vimrc

    set pythonthreedll = python36.dll
    

    Most distribution of vim in Windows is loading python dynamically, you must tell vim what the dll is, and make sure that python36.dll is in your PATH environment variable.

    0 讨论(0)
  • 2020-12-13 09:13

    Download the one called "OLE GUI executable"

    0 讨论(0)
  • 2020-12-13 09:14

    After trying all answers in this thread without success, the following worked for me (Win10, Python 2.7 32bit, gvim 7.4 32bit):

    1. Reinvoke the Python Installer, select Change Python
    2. Select the Option Add Python to Path, which is off by default
    3. After the installer is done, restart your machine
    0 讨论(0)
  • 2020-12-13 09:19

    I encountered this problem on Windows 7 64-bit. I realized I was using 64-bit Python 2.7.3 and 32-bit vim 7.3-46. I reinstalled both as 32-bit versions and then restarted the computer. Now it works.

    0 讨论(0)
  • 2020-12-13 09:21

    After reading the above, I can confirm that on Win8.1 it does matter the order you install them (least for me it did). I had 32bit VIM 7.4 installed for a few months, then tried adding Python and couldn't do it. Left Python 2.7.9 installed and uninstalled/reinstalled VIM and now it works.

    0 讨论(0)
  • 2020-12-13 09:21

    You will want to turn on syntax highlighting

    put syntax on in your in your vimrc (the format of the vimrc file will be the same on linux/windows or any other OS)

    Vim also supports autoindenting, if you want to enable auto indenting for python, have look at this guide here

    The key to enable autoindenting is to include the following in vimrc

    autocmd BufRead,BufNewFile *.py syntax on
    autocmd BufRead,BufNewFile *.py set ai
    autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
    
    0 讨论(0)
提交回复
热议问题