Question

I'm currently trying to emulate the way you can run scripts with F5 in IDLE in Vim. I've installed PyInteractive, an interactive Python Shell that works inside Vim. PyInteractive has a command PyInteractiveEval which I'm thinking I can use with execfile() and some mapping to emulate the IDLE functionality.

The issue I'm having is getting the path of my current file so I can pass it into execfile(). I tried %:p but that doesn't work.

Any help would be much appreciated.

Was it helpful?

Solution

Except for Ex commands like :edit, special symbols like % aren't automatically expanded. You need to use the Vimscript expand() function to explicitly do this. Then, interpolate the result (as a String) to the :PyInteractiveEval command, like this:

:execute 'PyInteractiveEval execfile(' . string(expand('%:p')) . ')'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top