获得带有 Python 3 支持的 Vim 的最简单方法是什么?

Cra*_*Man 19 vim python3

我安装了 Ubuntu 14.04,并且其存储库中的 Vim 是在没有 Python 3 支持的情况下编译的。因此,python-mode 插件不能与 Python 3 代码一起使用。获得带有 Python 3 支持的 Vim 的最简单方法是什么?

mur*_*uru 16

似乎在基于 Debian 的系统上(至少)你不能吃蛋糕也不能吃。它是 Python 2 或 Python 3。由于 Python 库的构建方式,您只能在 Vim 会话中使用一种变体。您可以使用两者进行构建,但如果在 Vim 中调用 Python 2,则不能在同一个会话中调用 Python 3,反之亦然。同样在 Arch Linux 上,Vim 仅使用 Python 2 ( vim, gvim) 或 Python 3 ( vim-python3, gvim-python3)之一编译。


16.04 之前

要重建存储库提供的 Vim:

sudo apt-get build-dep vim
apt-get source vim
cd vim-*  # it will be vim-7.4.something
Run Code Online (Sandbox Code Playgroud)

编辑debian/rules和替换:

ALLINTERPFLAGS+=--enable-pythoninterp --with-python-config-dir=$(shell python-config --configdir)
ALLINTERPFLAGS+=--disable-python3interp
Run Code Online (Sandbox Code Playgroud)

和:

ALLINTERPFLAGS+=--enable-pythoninterp=dynamic --with-python-config-dir=$(shell python-config --configdir)
ALLINTERPFLAGS+=--enable-python3interp=dynamic --with-python3-config-dir=$(shell python3-config --configdir)
Run Code Online (Sandbox Code Playgroud)

然后运行:

dpkg-buildpackage -us -uc
Run Code Online (Sandbox Code Playgroud)

吃午饭。(如果你用过,或者茶-j $(nproc)。)

现在,.deb将在父目录中创建多个文件。看看哪个:

cd ..
ls vim*.deb
Run Code Online (Sandbox Code Playgroud)

随着特定变体要安装(vimvim-gnomevim-gtk等),你必须安装vim-common_*.debvim-runtime_*.deb以及用于GUI版本vim-gui-common_*.deb。例如, withvim-gnomevim存储库中的当前版本:

sudo dpkg -i vim-gnome_7.4.052-1ubuntu3_amd64.deb vim-common_7.4.052-1ubuntu3_amd64.deb vim-gui-common_7.4.052-1ubuntu3_all.deb vim-runtime_7.4.052-1ubuntu3_all.deb
Run Code Online (Sandbox Code Playgroud)

然后:

$ vim --version | grep python
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
Run Code Online (Sandbox Code Playgroud)

PI-RHO的/ dev PPA建立vim以这种方式,这样你就可以使用PPA而不是手动构建它。


16.04

从 16.04 开始,Ubuntu 构建了支持 Python 3 的 Vim。Python 2中支持由提供-py2vim-nox-py2vim-gnome-py2等)。


有关的: