Reputation: 35557
How do I execute this code using gVim?
EDIT
If I use either :! python pi.py
or :w !python -
then I get the following:
Upvotes: 8
Views: 7680
Reputation: 14836
You don't need to save the file, you can run the current buffer as stdin to a command such as python
by typing:
:w !python -
(The hyphen at the end probably isn't necessary, python will generally use stdin by default)
edit: seeing as you are new to vim, note that this will not save the file, it will just run it. You will probably want to learn how to save your file.
Upvotes: 12
Reputation: 31419
If you have python support compiled into vim you can use :pyfile %
to run the current file. (python 2.7)
If you have python 3 support use :py3file %
instead
Upvotes: 5
Reputation: 567
It seems your %path% environment variable doesn't contain your python installation path.
Follow the following steps:
Note: change the directory to your python directory (could be c:\python30, for example)
Save everything and then - Close vim and all CMDs and try again.
Upvotes: 2
Reputation: 9384
Something like this. Type following command in vi command model.
:! python test.py
Upvotes: 4