vim对python的语法,格式等各方面支持不足,由python-mode插件补齐。

1、安装vim的插件系统 vim-plug,在win的powershell下运行:

iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
    ni $HOME/vimfiles/autoload/plug.vim -Force

2、测试vim对python3的支持情况.

###测试对python3的支持
:py3 print("hello,python3")
###显示vim下的python版本
:py3 import sys;print(sys.version)

3、安装python-mode,编辑 ~/vimfiles/vimrc

call plug#begin()
Plug 'python-mode/python-mode', { 'for': 'python', 'branch': 'develop' }
call plug#end()

运行: PlugInstall

4、解决 [Pymode]: error: Pymode requires vim compiled with +python3 (exclusively)

导致这个错误的原因是vim同时提供了对python2和python3的支持。但是vim 不能同时与 python2 和 3 一起正常工作。这时要给python-mode一个明确的指示到底用哪个版本的python

编辑vimrc配置文件:

### 添加系统环境下的python运行路径,若已经在系统变量添加可省略
set pythonthreehome="C:\Python38\"
let &pythonthreedll="C:\Python38\python38.dll"
let $PYTHONHOME="C:\Python38\"

###指定python版本
let g:pymode_python = 'python3'

参考链接:

https://github.com/python-mode/python-mode/issues/1064

5、默认的python-mode有些东西还是挺不习惯的,参照官网在修改一下。

https://github.com/python-mode/python-mode