VIM 安装和Anaconda

VIM installation and Anaconda

我正在使用 Anaconda 并且有一个 Python27 的环境,在不久的将来,一个 Python3。

我 运行 在 vim 使用绳索时遇到麻烦,b/c 我的原始构建与我的 /usr/local/vim 相关联(我认为..或类似的东西) .

我从阅读中意识到,我应该重新构建 vim:

./configure --enable-pythoninterp --with-python-config-dir=/home/wbg/anaconda/envs/py27/lib/python2.7/config --enable-prefix=/home/wbg

所以我想知道,是否有更好的方法来安装 vim,这样当我改变 Anaconda 环境时,我的 vim 也会改变。

TIA !

Vim can be built in four ways:

  1. No Python support (-python, -python3)
  2. Python 2 support only (+python or +python/dyn, -python3)
  3. Python 3 support only (-python, +python3 or +python3/dyn)
  4. Python 2 and 3 support (+python/dyn, +python3/dyn)

我认为你应该选择最后一个选项;但是,这种选择带来了一些额外的麻烦。当 Python 2 和 Python 3 都受支持时,它们必须动态加载。而且,您将无法在同一个 Vim 会话中使用 Python 2 或 3。您可以同时使用两者进行构建,但是一旦 python 的一个版本在 Vim 中被调用,另一个版本就不能。

在 windows 上,您需要启用 python 解释器的动态加载。如果在路径中找到 python,它将在 vim 中可用。这使您不必担心 python 的安装位置。例如:

./configure --with-features=huge --enable-pythoninterp=dynamic --enable-python3interp=dynamic

在 Debian-based 系统上,要构建 python 的两个版本,您需要使用类似的东西:

./configure --enable-pythoninterp=dynamic --with-python-config-dir=$(shell python-config --configdir) -enable-python3interp=dynamic --with-python3-config-dir=$(shell python3-config --configdir)  

(有关更多详细信息,请参阅:https://askubuntu.com/questions/585237/whats-the-easiest-way-to-get-vim-with-python-3-support)。

这是一个老问题,但我觉得这个问题很有用,所以在这里分享。

conda forged vim 负责 conda envs 和 python 链接:

conda install -c conda-forge vim

更多信息:https://anaconda.org/conda-forge/vim