Within a vim script it is possible to embed some python code, as long as vim is built with the +python
feature.
function! IcecreamInitialize()
python << EOF
class StrawberryIcecream:
def __call__(self):
print('EAT ME')
EOF
endfunction
However, some people have vim built with +python3
instead. This brings up some compatibility issues for vim plugins. Is there a generic command which calls whichever python version is installed on the computer?
This snippet could determine which Python version we're using and switch to it(Python stands for that version installed).
To load the python code, we first figure out its location(here under the same directory as the Vim Script):
Then check if the python module is available. If not, reload it:
Two ways to call it:
1.
2.