19

Yes, vim can be built with several different language interpreters available. This is something you (or your distro) picked when compiling vim from source. Available at least are Python (as you requested), Perl, Ruby, and Tcl. The vim documentation has details for each; the python one is in :help if_pyth.txt. That document has plenty of examples. For ...


17

I'm the current Vim maintainer for Debian and the person quoted in the referenced mailing list discussion. As you stated, this isn't a question about Vim. It's about building the software that Vim links against in a way that meets your needs. There's a more thorough discussion (at least for the Debian aspect) of the issue in a bug requesting Python3 to be ...


11

The pi-rho/dev PPA now supports Vim 8, and like it always has, includes support for Python/Python3: $ vim --version | grep python +cryptv +linebreak +python/dyn +vreplace +cscope +lispindent +python3/dyn +wildignore $ apt-cache policy vim vim: Installed: 2:8.0.0134-1ubuntu1~ppa1~x Candidate: 2:8.0.0134-1ubuntu1~...


10

You can use the pydo command available since Vim 7.4, the manual describe how it works better than I could: :[range]pydo {body} Execute Python function "def _vim_pydo(line, linenr): {body}" for each line in the [range], with the function arguments being set to the text of each line in turn, without a trailing <EOL>, and the current line ...


9

Try using the jedi-vim plugin. It uses Jedi to get completions and is much better at doing so than python-rope is. It will resolve np.array to numpy.array and show the appropriate documentation in a tab/split. Be warned that numpy is notoriously slow for Jedi to resolve when it's not cached. zondo's suggestion to use :!pydoc numpy.array does work, but I ...


9

TL;DR: Requiring +python/+python3 support for a python based development plugin. That sounds completely reasonable. About Vim plugins and human behavior Generally, speaking humans want things to appear simple and "just work". When it comes to Vim plugins, Vimmers typically want plugins with no or very few dependencies. Basically it should be as simple as ...


8

I was able to fix it myself by providing jedi-vim with the location of the packages in my anaconda folder using the $PYTHONPATH variable as follows: export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-packages Thanks to all! Or Add following line in ~/.bash_profile export PYTHONPATH=$PYTHONPATH:/home/user1/anaconda3/lib/python3.5/site-...


8

From your question it appears that you have installed vim-tiny 8.0 that is a very minimal Vim runtime without plugins. You can confirm this using this: dpkg -l | grep vim You can have several Vim runtimes, but the version running when you do vim will be the version that you can see indicated here: update-alternatives --list vim You can check other ...


7

You can get the current buffer with vim.current.buffer, which is an iterable; you can use use a for loop to get each line. You can change the lines by assigning to them; so putting that together, we get: :py from vim import * :py for i, line in enumerate(current.buffer): current.buffer[i] = '[%s]' % line Also see :help python-buffer.


7

All right, apparently the state is this: VIM on Windows supports python 2.7.9, not 2.7.11. It might work with 2.7.10, I did not test it. Even though I compiled VIM on Windows with a reference to the 2.7.11 DLL, it suddenly worked when I tried swapping out 2.7.11 for 2.7.9 I'm not sure if I did something wrong with 2.7.11, and it actually does work, but I ...


7

You need to install Python yourself on Windows. If you type :version, you should see +python/dyn and +python3/dyn. On Windows, this means that Vim is compiled to dynamically load the Python DLL. You can read about this in :h python-dyanmic. Depending on the versions you install, you may want to look at :h pythondll and :h pythonthreedll If you install ...


6

Thanks to x33a on the Arch forums, I was able to solve my problem. (https://bbs.archlinux.org/viewtopic.php?pid=1596987#p1596987) I changed the python 3 flag from --enable-python3interp=dyanmic to --enable-python3interp This resulted in only python 3 being available.


6

Yes, you can create routines with high level languages such as python, ruby, perl, among other. To see what languages your vim supports: vim --version


6

you should use sudo apt-get install vim-nox instead, to get a "huge-version".


6

See help pythonx in Vim 8: Because most python code can be written so that it works with python 2.6+ and python 3 the pyx* functions and commands have been written. They work exactly the same as the Python 2 and 3 variants, but select the Python version using the 'pyxversion' setting.


5

You can use the vim package inside python, you should be able to gain access to vim: function! Test(myArgument) python << EOF import vim def test(myArgument): print "My argument " + myArgument test(vim.eval('a:myArgument')) EOF endfunction You can read about the python integration at :h python and about this particular feature at :h python-...


5

To use Python in Vim, your Vim must be compiled with support for it. Most Linux distributions (Debian-based, CentOS, Arch, for example) have support for Python2, but not for Python3. To check for Python support you can use: :echo has('python') :echo has('python3') If it echoes 1, it means Vim has this feature (python is Python 2). If it echoes 0, it means ...


5

Your function returns nothing, but you call it expecting the buffer number. This should work: function! ScratchBuffer() vnew setlocal nobuflisted buftype=nofile bufhidden=wipe noswapfile return bufnr('%') endfunction


5

You should install vim from source. That way, you have control over what is included. See the following for more info and a step by step walkthrough. It is relatively easy. https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source https://github.com/vim/vim


5

If you want to avoid rewriting the Python script, put it in a separate file and use :pyfile or :py3file instead. let script_path = expand('<sfile>:p:h') . '/script.py' if !has('python') and !has('python3') finish endif execute (has('python3') ? 'py3file' : 'pyfile') script_path This will load script.py that's in the same directory.


4

The problem was not in Vim's default Python interpreter. The real root of the problem is that the last version of jedi-vim (0.7.0) was released in 2013 and did not work well with Python 3. Since then Python 3 support in jedi-vim has been improved a lot. We (Arch users) asked jedi-vim to make a new release. 0.8.0 has been released and now it is in the Arch ...


4

That's what pyeval() is good for. The only (minor) inconvenience is that you have to quote the expression you want to evaluate: let @a = pyeval('sum([x^2 for x in range(100)])') It works for all data types, and you can do with it everything you can do with a Vim expression. For example: echo pyeval('[x^2 for x in range(100)]')


4

Ubuntu 16.04 now has vim-*-py2 packages included in the repo. This means all Debian Vim users can migrate to Ubuntu if needed. The erstwhile vim-* packages now provide +python3, and the binaries are named differently to avoid conflict: vim.nox for vim-nox and +python3 vim.nox-py2 for vim-nox-py2 and +python And so on.


4

You can't. The :python and :python3 commands always use the compiled-in interpreters. If you have a recent version of Vim with python and / or python3 loaded dynamically (see :h python-dynamic) you can use pythondll and pythonthreedll to load different interpreters, but replacing CPython by Anaconda is IMO asking for segfaults (provided that Vim accepts it ...


4

Solution 1 : Install VIM Editor(Install any one of them of vim variant) : vim-gtk3 :- This package contains a version of vim compiled with a GTK3 GUI and support for scripting with Lua, Perl, Python, Ruby, and Tcl. In order to install this package : sudo apt install vim-gtk3 vim-gtk :- This package contains a version of vim compiled with a GTK2 ...


4

Have a look at :help python3 and the subsequent sections on python-2-and-3 and pythonx. If python is compiled with +python/dyn, +python3/dyn, then it effectively has support for Python 2 and 3. Checking available version. You can test what Python version is available with: if has('python') echo 'there is Python 2.x' endif if has('python3') ...


4

Probably your default python3 is 3.6. You need, then, tell the build process to use python3.7. You can do that with the parameters --with-python3-command: ./configure --with-python3-command=python3.7 \ --with-python3-config-dir=/usr/lib/python3.7/config-3.7m-x86_64-linux-gnu \ ... (other config params) ... HTH


4

I'm not aware that you can create a hidden unnamed buffer. But you can create a hidden (even unlisted) buffer with some fancy name and use that. In VimScript: let g:myscratch = bufnr("my-fancy-name", 1) call setbufvar(g:myscratch, "&buftype", "nofile") The first line returns the buffer number for the buffer named "my-fancy-name". If the buffer does ...


3

If you want more features (and something more up to date than whats in the apt packages), you have to compile it yourself. You say you are on Debian, and all these should work on that platform. You will first want to clone the repo and remove any existing vim installations. git clone https://github.com/vim/vim.git sudo apt-get remove --purge vim* Next,...


3

Your problem is that you're starting a Neovim subprocess and it's blocking before processing the rest of your script. When you quit Neovim, the rest of the script executes well after the file socket has outlived its use to Neovim. You will need to start it from a thread so that the rest of the script can execute. #!/usr/bin/env python import os import ...


Only top voted, non community-wiki answers of a minimum length are eligible