For questions about The Python interface to Vim; DO NOT use for questions with Python examples or about syntax highlighting in Python.
Questions tagged [vimscript-python]
104 questions
23
votes
2 answers
Can I script Vim using Python?
Vimscript looks somewhat similar to Python code.
Can Vim be integrated with high-level language interpreters, such as Python?
peterh
- 1,147
- 3
- 16
- 35
11
votes
2 answers
How to execute python statement for each line?
I've the following sample code which modifies the current line using Python statement:
:py import vim; vim.current.line="["+vim.current.line+"]"
How I can execute this statement for each line in the current file?
Related: How can you use Python in…
kenorb
- 18,433
- 18
- 72
- 134
5
votes
1 answer
How can I get python library help in vim?
I tried python-mode, it seems that it can work when I press K on "numpy.array", but if I want to press K on "np.array", it won't work.
yihui.dev
- 153
- 4
4
votes
0 answers
How to fix which python executable vim is using?
For the python command vim uses the python exetuable it finds first in the $PATH variable. However, for me this can change depending what project I work on (using virtual environments). Is there a way to fix this to one particular executable?
NB. On…
Hielke Walinga
- 163
- 6
3
votes
2 answers
Inserting text with the Python interface
I would like to insert some Python-generated text at the current cursor position in insert mode using the Vim Python interface. The closest I have so far is:
imap :python vim.current.line += "trivial example"
This will append…
Annika Backstrom
- 131
- 2
3
votes
1 answer
requires Vim compiled with Python (2.7.1+ or 3.4+) support
I compiled vim8.1 with the following options :
$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 18 2018 09:50:18)
Included patches: 1-320
Compiled by mohsen@ns1
Huge version with GTK2 GUI. Features included (+) or not (-):
+acl …
PersianGulf
- 259
- 1
- 3
- 10
2
votes
0 answers
Vim using wrong executable and site packages in Python venv
Issue
I am using Vim within an activated Python virtual environment i.e. I have run
python3 -m pip venv env
. env/bin/activate
However when I am editing a Python file, then Ale is complaining about import errors for third party packages. These are…
rwolst
- 405
- 1
- 3
- 5
1
vote
2 answers
Vim python backend, how to import user installed shared libraries?
I (very) often write python, and I use Vim's python3 backend to test my code. To perform my tests I use:
vnoremap p y:"python3
It simply takes my visual selection and runs within Vim's python backend. This is very…
grochmal
- 1,656
- 14
- 35
1
vote
0 answers
Is it possible to start python thread from inside Vim under HP-UX?
I've compiled Python 2.7.10 and Vim 7.4 with Python support (HP-UX 11.31 ia64).
Everything seems to be working well except for threads. Here's simple example.
from threading import Thread
from time import sleep
def threaded_function(arg):
for i…
notdoneyet
- 13
- 2
1
vote
1 answer
Programming Vim in Python: how is it implemented?
Somebody told me that it is possible to write Vim plugins in Python.
I would like to inspect the source implementing this: I would like to use another scripting language for that.
Is there a documentation on how the authors implemented this Python…
Gergely
- 293
- 2
- 6
1
vote
0 answers
How to return from vimscript.python?
I have a script written in vimscript-python, e.g.:
function! MyFunction()
python3 << EOF
# if :
# return
print('Hello world')
EOF
endfunction
I want to add a check in the beginning of the script and if a check fails, the functions…
niekas
- 1,575
- 4
- 17
- 25
1
vote
0 answers
Simplest way for a clean uninstall/install of vim with python support
I have vim that is compiled with an outdated version of python (3.4).
I have install python into a local directory and verified it works properly:
$ which python3.7
/usr/local/bin/python3.7
What would be the simplest way to uninstall and re-install…
David542
- 2,445
- 14
- 50
1
vote
1 answer
run vim without python3 suppport
I have python2 and python3 compiled into my vim
vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 2 2019 14:25:42)
Included patches: 1-2109
Compiled by user@enterprise
Huge version with GTK2 GUI. Features included (+) or not…
flashburn
- 689
- 6
- 17
1
vote
1 answer
How to set internal vim variable from python code
I'm trying to write vim plugin for easier work with cmake. I want it to read some values from json file: build_dir, generator, cmake VARS and then give vim user few functions: configure, build, maybe run.
I decided to use python, because it's easy…
Nikita Kiselevskiy
- 21
- 2
1
vote
1 answer
Why is Vim's Python version compiled in?
My machines have Python 3.7 installed. On my Ubuntu machine I have no issues, but on my Windows 10 machine, I can't run Python plugins in Vim. The reason is that the Windows Vim as distributed has been compiled for Python 3.6, and Vim will only use…
Scott Severance
- 367
- 4
- 11