Need a vim consultation on migrating to python3

I use Vim as the main editor / IDE for all my Django projects. Using YouCompleteMe, syntax and several other plugins. The experience is fantastic.

I decided to start all new projects with python3 when the world moves to Py3K. But vim does not play correctly with both versions of python.

I compiled with both versions of python.

vim --version | grep python +cryptv +linebreak +python/dyn +viminfo +cscope +lispindent +python3/dyn +vreplace 

YouCompleteMe does not yet support python3. jedi-vim works with both versions, but I do not just understand this.

Usually without any plugins I can call any py / py3 command. But turning on jedi-vim automatically calls the python2 system.

I am using Vundle as a vim plugin manager.

If you please share your vimrc / other configurations / workarounds in order to use vim to develop python3 (or both versions), which is very useful for me.

Thanks.

+5
source share
1 answer

As other people point out in the comments, you don’t have to change Vim configuration much to switch to Python3. What you need to do is identify the plugins that use the built-in Python (s), find out which ones support both Python2 and Python3, and tell them that they prefer Python3, and disable those that only work with Python2.

For the plugins that I use:

  • gundo: let g:gundo_prefer_python3 = 1
  • jedi: let g:jedi#force_py_version = 3
  • syntastic: let g:syntastic_python_python_exec = 'python3' and install versions of all Python3 checkers
  • python-mode: let g:pymode_python = 'python3'
  • YouCompleteMe: does not work with Python3.

It is also nice to have if you plan to edit VimL files using the py and py3 : set the excellent SyntaxRange and add this to after/syntax/vim.vim :

call SyntaxRange#Include('\C\v<py\%(thon)?3?\s+\<\<\s*[AZ]{3,}\zs$', '\C\v^[AZ]{3,}$', 'python') cases>

+5
source

All Articles