I'm using Vim as my primary editor/IDE for all of my Django projects. Using YouCompleteMe, syntastic and a couple of other plug-ins. The experience is fantastic.
I've decided to start all new projects with python3 as the world is moving to Py3K. But vim is not playing right with both versions of python.
I'm compiled with both versions of python.
vim --version | grep python
+cryptv +linebreak +python/dyn +viminfo
+cscope +lispindent +python3/dyn +vreplace
YouCompleteMe don't support python3 yet. jedi-vim works with both versions but I'm not just getting it right.
Usually without any plugins I can invoke any of py/py3 command. But enabling jedi-vim it automatically calls system python2.
I'm using Vundle as vim plug-in manager.
If you please share your vimrc/other configurations/workarounds to use vim for python3 development (or both versions) that'll very helpful for me.
Thanks.
Run :ve[rsion] in command-line mode or run vim --version from Bash. If vim was compiled with Python 3, you'll find -python and +python3 . If vim was compiled with Python 2, you'll find +python and -python3 . If vim was compiled without Python support, you'll find -python and -python3 1.
Using Vim as a Python IDE The python-mode project is a Vim plugin with syntax highlighting, breakpoints, PEP8 linting, code completion and many other features you'd expect from an integrated development environment.
Write Your Python Script To write in the vim editor, press i to switch to insert mode. Write the best python script in the world. Press esc to leave the editing mode. Write the command :wq to save and quite the vim editor ( w for write and q for quit ).
As other people point out in comments, you don't need to change much in terms of Vim config in order to switch to Python3. What you do need to do is identify plugins that use the embedded Python(s), find out which of them support both Python2 and Python3 and tell them to prefer Python3, and phase out those that only work with Python2.
For the plugins I'm using:
let g:gundo_prefer_python3 = 1
let g:jedi#force_py_version = 3
let g:syntastic_python_python_exec = 'python3'
, and install the Python3 versions of all checkerslet g:pymode_python = 'python3'
Also, nice to have if you plan to edit VimL files with py
and py3
commands: install the excellent SyntaxRange, and add this to after/syntax/vim.vim
:
call SyntaxRange#Include('\C\v<py\%(thon)?3?\s+\<\<\s*[A-Z]{3,}\zs$', '\C\v^[A-Z]{3,}$', 'python')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With