문제

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