19 votes
Accepted

Can I script Vim using Python?

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 ...
  • 1,845
17 votes

How do I get Vim to be able to run both python and python3 on a Linux system in the same session?

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 ...
  • 10.5k
15 votes
Accepted

Vim 8.0 Python support

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 ...
  • 24k
12 votes
Accepted

Installing or building vim with +python3 support for Python 3.7.x on linux

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 ...
11 votes

Installing or building vim with +python3 support for Python 3.7.x on linux

make clean distclean before running the configure command for vim. This worked for me. There was lots of cached items hanging around from before that were interfering with vim configure.
10 votes
Accepted

How to execute python statement for each line?

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}" ...
  • 4,522
10 votes

How to get Python support on MS Windows?

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 ...
  • 6,420
9 votes
Accepted

How can I get python library help in vim?

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 ...
  • 6,420
9 votes
Accepted

Drawbacks of using Python to develop new code in a VIM plugin

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 ...
8 votes
Accepted

how to change python interpreter used by jedi-vim

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/...
  • 311
8 votes

Vim 8.0 Python support

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 ...
8 votes
Accepted

requires Vim compiled with Python (2.7.1+ or 3.4+) support

When you want to run ./configure, You have 3 options for python: --enable-pythoninterp=yes --with-python-command=/usr/bin/python --with-python-config-dir= last parameter is deprecated, You have to ...
7 votes
Accepted

How to detect the buffer number of new buffer

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 ...
  • 9,340
7 votes
Accepted

How can I build vim with just python 3 support?

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 ...
7 votes
Accepted

How do I use Python plugins on Windows?

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 ...
  • 311
7 votes

How to execute python statement for each line?

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 ...
7 votes

Vim 8.0 Python support

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

How to use the argument of a vimscript function in an inner python function?

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 " + ...
  • 15.3k
6 votes
Accepted

Making a box in vim via python

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 ...
  • 24k
6 votes

Can I script Vim using Python?

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
  • 271
6 votes

Vim 8.0 Python support

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, ...
  • 271
6 votes
Accepted

How to write a plugin that works for both Python3 and python?

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 ...
  • 2,728
6 votes
Accepted

Creating a hidden buffer

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-...
  • 8,725
5 votes

How can I build vim with just python 3 support?

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 ...
5 votes

Calculating with python and appending result to file or register

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 ...
  • 3,889
5 votes

Vim 8.0 Python support

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/...
5 votes

Elegant way to support both python and python3 in vim plugin

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 !...
  • 6,420
5 votes
Accepted

Vim is unable to find Python

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. ...
5 votes
Accepted

Quit script after a certain condition is true

Use :finish: if hasNoDependency() finish endif " all dependencies are met, good to go " ... I use it for minpac plugin manager (not only here of course): if !exists('*minpac#init') | ...
  • 10.9k
4 votes

How do I get Vim to be able to run both python and python3 on a Linux system in the same session?

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 ...

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