How do I execute this code using gVim?
EDIT
If I use either :! python pi.py
or :w !python -
then I get the following:
The improved version of vi editor is Vim that can be used for creating or editing source codes of different types of programming or scripting languages. It is a configurable text editor and works faster than other command-based text editors. It can also work with various plugins and vimscript.
Write Your Python Script To write in the vim editor, press i to switch to insert mode. Write the best python script in the world. Press esc to leave the editing mode. Write the command :wq to save and quite the vim editor ( w for write and q for quit ).
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.
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
pyfile help
Something like this. Type following command in vi command model.
:! python test.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With