سؤال

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