Questions tagged [vimscript-python]
For questions about the Python interface to Vim. For questions about editing Python source code, use [filetype-python] instead.
108 questions
1
vote
3
answers
153
views
Vim python3 version referring to python3.8 instead of python3.13
Whenever I open vim and type :python3 import sys; print(sys.version), it returns python3.8. I want python3 in vim to refer to python3.13. How do I do this? I'm not using NeoVim.
0
votes
0
answers
66
views
Run vimscript+python user commands sequentually?
I am running vim 8.2.2121.
I am trying to open 3 tabs
One tab has instructions in it and is opened read only.
Both tabs 2 and 3 create :new files and read template files into them on separate tabs.
...
1
vote
1
answer
43
views
Why does Black's Vim plugin generates list of cursors?
I've been looking at the plugin implementation of Black and I don't understand this part of the implementation
for i, tabpage in enumerate(vim.tabpages):
if tabpage.valid:
for j, window ...
1
vote
1
answer
553
views
No python3 provider found
When I try to run a Pyhton expression, I get that there is not python provider:
:lua vim.fn.py3eval("2+2") ...
0
votes
2
answers
43
views
How to open a file with "|" in the name from python3 function?
A file with | in the name confuses vim.
Example file:
/tmp/Testchars/UTF8 Grin |😬|..
The plugin tries to run:
vim.command(f"edit {chosen_file}")
But Vim interprets the | as a filter:
vim....
2
votes
1
answer
107
views
How to change the internal vim python sys.path?
I have learned that py3eval('print(sys.path)') return the sys.path used internally by Vim.
Say that i want add a new_path to the current sys.path. How shall I do?
I would appreciate solutions that ...
0
votes
1
answer
106
views
Pass local variables in a vimscript function to python
For example, I want to use default arguments:
function! MakeOrgTable(...)
let l:num_col = a:0 > 0? (a:0) : 0;
python << EOF
import vim
vim.current.buffer[:]=make_table(vim.current.buffer, ...
-1
votes
1
answer
67
views
How to replace between two marks with the content of a python variable
I'm writing a plugin to convert between word cases, and I would like to apply my filter between two marks.
The conversion part is done with python, but I don't know how can I replace the text between ...
2
votes
1
answer
98
views
How can make every line contain 80 characters when to insert lorem ipsum string?
set textwidth=80 in my .vimrc.
I have written a function to create a lorem ipsum:
function! Lorem(num)
python3 << EOF
import random
num = int(vim.eval("a:num"))
words = ['...
0
votes
1
answer
146
views
How can write the string in the cursor's position?
I write the function in my .vimrc which can convert string into its uppercase.
function! Cap(string)
python3 << EOF
s = vim.eval("a:string")
print(s.upper())
EOF
endfunction
Now i ...
1
vote
1
answer
66
views
How can make the trigger_word as argument to python?
The syntax of UltiSnips's snippet is as below:
snippet trigger_word [ "description" [ options ] ]
The upper method can convert all characters in the string into upper case:
"string&...
0
votes
1
answer
134
views
How can call python in snippet?
I want to expand ptest into welcome python in file ending with html. Add these lines in html.snippets(located in vim-snippets/UltiSnips):
snippet ptest
!p print("welcome python")
endsnippet
...
1
vote
1
answer
1k
views
The python library could not be loaded
I am trying to get UltiSnips to work with gVim on my Windows 10 machine and for some reason I keep getting the error:
Error detected while processing function UltiSnips #TrackChange:
line 1:
E370: ...
1
vote
0
answers
33
views
I am developing my own python package, but Omnicomplete won't recognize it
I have my package in a local folder (say C:/Users/Myself/PythonStuff/MyPackage).
Next, I created a new file in C:/Users/Myself/PythonStuff where I import my package, i.e. on top of my new file I have
...
1
vote
2
answers
83
views
Can I skip vimscript indentation inside conditional blocks
I'm editing my ~/.vimrc this weekend, and I've run into a use case that seems to beg that I strip off indentation in an if-block.
Broken use-case in my ~/.vimrc (with if-block indentation):
if has('...