How would I do the following in vim using pyx ?

let abc = 123
pythonx print (abc)
# >>> NameError: name 'abc' is not defined

From above, it looks like python doesn't have access to the vim namespace, so is there a way to do the inverse of:

pythonx vim.command("let abc=%s" % 123)

vim.eval() to use Vim variables/expressions from Python. =>

# python code
print vim.eval('g:foobar')

pyxeval() for the other way around.

" vim code
:echo pyxeval('somePythonFunc("foo") + 42')
| improve this answer | |
  • great. Here's my example: pythonx a=909; vim.command('let a=%s' % a) echom 'The python variable a is: ' . a – David542 Jun 21 at 1:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.