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.

有帮助吗?

解决方案

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')) . ')'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top