Skip to content
Advertisement

How to pass arguments from vimscript functions to python interface?

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?

Advertisement

Answer

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
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement