Questions tagged [vimscript-python]
For questions about The Python interface to Vim; DO NOT use for questions with Python examples or about syntax highlighting in Python.
87
questions
1
vote
1answer
221 views
How to use TexMathZones in Markdown Syntax, for Snippets?
I am a recent and very happy Vim User.
I write Mathematics and Computer Science Lecture Notes in Markdown Files, organized in a Vimwiki.
I use the UltiSnips Snippet Plugin.
This plugin provides me ...
1
vote
1answer
50 views
Stop vim from deleting expanded tab as a block of spaces
I am on CentOS 8.1 and using vim 8.0.1763. When I open a python file, e.g. vim tmp.py, I type tab and it inserts 4 spaces (see .vimrc below). When I type delete, it deletes all 4 spaces. I want it ...
2
votes
1answer
92 views
Contextual Snippets in UltiSnips not working
I have been using vimtex with UltiSnips for a while on Linux platform and it has been working just fine.
Recently, I switched to MacBook Air M1 for the same and installed the above mentioned plugins ...
0
votes
1answer
41 views
Solving issue with clang-format-vim.py saving new buffer
Summary
I configured vim to call clang-format.py following the steps in the clang documentation for vim integration. But when I save a new buffer the plugin fails. I'm new to vimscript and trying to ...
1
vote
2answers
1k views
Python support using pyenv
I am at the end of hour-long research on why I cannot install vim with proper python support. Problems already recognized: Impossible to install python 2 and 3 support together on ubuntu 16.04; oh ...
0
votes
1answer
4k views
How do I configure the python location?
The python I want to use is located at C:\randomplace\python.
I have a dev machine that has multiple instances of python (so relying on finding python in$PATH is unreliable).
How do I configure vim ...
1
vote
0answers
20 views
How can you isolate the date portion of each request of a IP adress? [closed]
How can you isolate the date portion of each request of a IP address if it's at the first line of each request from a log file using awk, creating a list of distinct dates, and then using grep to ...
0
votes
1answer
171 views
Gvim E370: cannot load library python36.dll with installed Python 3.8
I get often error E370: cannot load library python36.dll while using different plugins like: Fugitive.vim. I have Python 3.8 install with proper PATH.
Is it possible to force Gvim to use python38.dll ...
2
votes
0answers
25 views
Running a python command with terminal-generated signals enabled
I'm trying to do a long blocking read call inside a python script supplied with the python command:
python3 << EOF
import ctypes
libc=ctypes.CDLL("libc.so.6")
ch = ctypes.create_string_buffer(1)...
1
vote
1answer
189 views
python vs pyx in vim
I'm a bit confused as to what the difference is between python and pyx in vim, other than one seems to work and the other does not. For example:
pyx print ("OK")
This works, however, this ...
0
votes
1answer
49 views
Python script not running through vim but runs on Windows CMD
I have recently switched to vim from VS Code. I have Vim 8.2.
I have put these lines in my _vimrc file so that I can run python in vim by pressing F9:-
autocmd FileType python map <buffer> <...
2
votes
0answers
95 views
YouCompleteMe unavailable: unable to load Python [duplicate]
I have done PlugInstall but it gives:
YouCompleteMe unavailable: unable to load Python.
The same error happens while loading UltiSnips:
E370: Could not load python36.dll
My vimrc:
set rnu
set nu
...
7
votes
1answer
7k views
How to get Python support on MS Windows?
I've installed the latest version of Vim to date (8.0) for Windows. But the version of Vim I've got does not have Python support. I've downloaded the .exe version directly from vim.org.
echo has('...
1
vote
0answers
122 views
YouCompleteMe cannot find module
I am trying to get YCM working on Windows 10.
Vim version: 8.1 64-bit GUI
Since I'm using the regular gvim installer for Windows I have python support
Compiler flags as follows:
Compilation: cl -c /...
0
votes
2answers
606 views
How to let Vim work with pyenv?
I've created some Python virtual environments:
hmanx ~ Ā» pyenv virtualenvs
3.7.4/envs/nn (created from /home/roach/.pyenv/versions/3.7.4)
3.8.2/envs/py38 (created from /home/roach/.pyenv/versions/...
1
vote
0answers
22 views
How to return from vimscript.python?
I have a script written in vimscript-python, e.g.:
function! MyFunction()
python3 << EOF
# if <condition>:
# return
print('Hello world')
EOF
endfunction
I want to add a check in ...
1
vote
1answer
47 views
Quit script after a certain condition is true
I have a script that checks for a certain condition (it checks if pip dependencies are installed). If they are installed and everything is ok, I want to import a bunch of python functions from my ...
1
vote
0answers
35 views
Simplest way for a clean uninstall/install of vim with python support [duplicate]
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 ...
12
votes
7answers
12k views
how to change python interpreter used by jedi-vim
I have Anaconda (including python3.5.2), VIM (7.4) and Jedi-VIM installed on my system. There was also a python installed on the linux system by default.
The autocompletion is working on base ...
2
votes
1answer
935 views
Ultisnips py3 errors
I have these following errors whenever I try to get into insert mode (see images). I am confused about how to resolve them. I did try uninstalling and reinstalling SirVer/ultisnips, but didn't change ...
1
vote
1answer
68 views
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 ...
3
votes
2answers
915 views
The :python command doesn't work - E319: Sorry, the command is not available in this version
I am trying to use Python in vim, but it doesn't work despite vim having the +python3 option.
:python print("hello")
gives
E319: Sorry, the command is not available in this version
Question: How ...
2
votes
0answers
66 views
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 ...
13
votes
3answers
16k views
Installing or building vim with +python3 support for Python 3.7.x on linux
I've got Vim installed on MacOS using Brew and it installs with +python3 support for Python 3.7.2 by default.
I'm writing a Vim plugin which utilises some Python 3.7 and would like this to be able to ...
1
vote
3answers
195 views
vim : how to set current buffer to a string using `:python`
As example, my current buffer contains below lines
di=01;34
ln=01;36
mh=00
pi=40;33
I want to join all lines with :, and set entire buffer to the joined string.
How to achieve that, using :python ...
0
votes
1answer
94 views
How do I split a vim Window using python?
The vim documentation of the Python interface to vim mentions:
The height attribute is writable only if the screen is split horizontally.
The width attribute is writable only if the screen is ...
3
votes
2answers
236 views
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 <c-x><c-r> <c-o>:...
7
votes
1answer
4k views
Trying to compile vim with python 3.6. Where is my config directory?
I'm a bit of a noob when it comes to Linux, only started using it recently.
However, I am trying to compile vim with python because I am using latex live preview and it needs a python compiled vim ...
0
votes
1answer
166 views
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 ...
2
votes
1answer
88 views
Return <motion> character from Python function in <expr> mapping
I am trying to return this :GrepperAck ''<Left> from a Python function and use it in the following mapping
def invoke_search_command():
return ":GrepperAck ''<Left>"
:nnoremap <expr&...
2
votes
1answer
117 views
How to assign a Python list to a vim variable and escape its strings correctly
Here is a Python list that I'm trying to assign to some Vim variable.
lines = ['"""Something foo\'s thing."""', '', 'foo = "asdfasdf" \\', 'bar']
command = 'let l:corrected_lines = {lines}'.format(...
0
votes
1answer
257 views
configure VIM with Python support for Debian 9.4 VM Instance
I'm trying to configure VIM with Python support in order to use the You Complete Me pluggin.
This question has been asked before. Unfortunately none of the answers have worked for me. Any suggestions ...
1
vote
0answers
525 views
Vim shows error when running python3
OS: Ubuntu 18.04
First, I ran
apt-get install python3-dev ruby-dev
Then, I installed vim using the instructions in the website, using make distclean, make and make install (This was like the tenth ...
1
vote
0answers
120 views
How to use visual mode in python/dyn?
Vim documentation states how to run command and normal mode commands (source):
vim.command(str) python-command
Executes the vim (ex-mode) command str. ...
1
vote
0answers
217 views
Where could I find documentation of python/dyn or python3/dyn?
I guess that :py command is executed by some kind of extended Python interpreter. This extended Python has vim package available:
:py import vim; print(dir(vim)); print(vim.__package__, vim.__name__)
...
1
vote
1answer
755 views
Creating a hidden buffer
I know that with commands like sbuffer you can create a new buffer and display it in a split window, and commands like enew can create a new buffer in the current window. But is it possible to not ...
1
vote
0answers
68 views
Why does vim work if command file is double clicked, but not from DOS?
(Windows7-64bits-Vim8.1)
I have a problem with getting the python in Vim to work. This problem is probably caused because I do not have admin access to the machine; I can't help that.
In order to ...
26
votes
7answers
36k views
Vim 8.0 Python support
I'm trying to upgrade my Vim installation to version 8.0, but it doesn't support both Python and Python 3 as the below image.
(PS: Because of this problem, I cannot use the YCM (YouCompleteMe) plugin ...
1
vote
0answers
229 views
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 ...
1
vote
1answer
1k views
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 ...
3
votes
4answers
364 views
How to run a python command based on a matched group of a pattern?
Let say I want to run a command that uses a matched group of a pattern for each line matching the pattern.
The natural choice is :g.
With the command :s, there is no problem. If i would do
:g/aaa\(....
3
votes
1answer
9k views
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 ...
1
vote
0answers
249 views
How vim invokes and executes python interpreter
What is happening under the hood when we type :w !python3 in VIM. Does it invoke the system-wide python3 or the one present in the virtual environment?
My script:
import sys
sys.path.append('./...
2
votes
1answer
928 views
Vim is unable to find Python
I'm using Vim on Fedora 28 and Python seems to be enabled:
vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jul 11 2018 10:00:51)
Included patches: 1-177
Modified by <bugzilla@redhat.com&...
0
votes
0answers
54 views
`vim.eval('a:items')` fails if 'a:items' contain `BOM HEADERs`
I am using a pluging ctrlp-py-matcher, which is using the python interface to
vim. My VIM is compiled with python3 support
VIM - Vi IMproved 8.1 (2018 May 17, compiled Jul 1 2018 10:45:10) Included
...
0
votes
1answer
179 views
Python integration not working as usual
I am compiling Vim on Linux (18.04 Ubuntu) on a new environment and I am experiencing an issue with a lot of my vimrc configuration, which has some inline python logic.
Basically the python code just ...
4
votes
1answer
2k views
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.
1
vote
1answer
54 views
Is `width` a parameter of the Python object `vim.current.window`?
I am trying to use PYthon to interface with VIM in my vimrc. I am aware that
this can be done in vimrc in VIML, but I don't want to learn VIML too much,
and am already familiar with Python.
I looked ...
1
vote
0answers
76 views
Vim package development python support for 2, 3, or both?
Apparently there are some issues preventing vim from being built with both python and python3 support under many linux distributions and OSX. This makes it difficult or impossible for many users to ...
0
votes
1answer
917 views
passing arguments to pyfile/py3file function
I try to do something similar to this question.
E.g. I have a python script in a file /tmp/testme.py which should do different things depending on what argum
ents are passed to it:
import vim
...