Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass arguments from vimscript functions to python interface?

Tags:

python

vim

For example, processing positional arguments:

function! Example(arg)
python <<_EOF_

# do something with a:arg

_EOF_
endfunction

or the ... list:

function! Example(...)
python <<_EOF_

# do something with a:000, a:1, a:2, etc.

_EOF_
endfunction

Is there anyway I can do this?

like image 562
Meow Avatar asked Jan 12 '15 11:01

Meow


1 Answers

You can retrieve the function arguments just like any other Vimscript expression through vim.eval():

function! Example(arg)
python << _EOF_

import vim
print "arg is " + vim.eval("a:arg")

_EOF_
endfunction
like image 85
Ingo Karkat Avatar answered Sep 24 '22 22:09

Ingo Karkat