Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.
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 ...
user avatar
  • 1,815
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 ...
user avatar
  • 10.3k
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 ...
user avatar
  • 23.7k
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 ...
user avatar
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}" ...
user avatar
  • 4,452
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 ...
user avatar
  • 6,320
10 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.
user avatar
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 ...
user avatar
  • 6,320
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 ...
user avatar
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/...
user avatar
  • 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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
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 ...
user avatar
  • 9,260
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 ...
user avatar
  • 311
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 " + ...
user avatar
  • 15k
6 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 ...
user avatar
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 ...
user avatar
  • 23.7k
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
user avatar
  • 271
6 votes

Vim 8.0 Python support

you should use sudo apt-get install vim-nox instead, to get a "huge-version".
user avatar
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, ...
user avatar
  • 261
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 ...
user avatar
  • 2,603
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-...
user avatar
  • 8,520
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 ...
user avatar
  • 3,849
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/...
user avatar
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 !...
user avatar
  • 6,320
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') | ...
user avatar
  • 9,773
4 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 ...
user avatar
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 ...
user avatar
4 votes

how to change python interpreter used by jedi-vim

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 ...
user avatar
  • 3,849

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