Instead of saving and closing the scrip¬† and run from Terminal each time,¬† while you are in vim press “Esc” and run the fowling in vim command mode :

:w !python3 %

w : is for saving the current file

python means run the script by python.

! : is for run using shell

% : represents the current filename in vim.


note: you can use this form with other interpreter,

How to Run Python Script While In Vim

Leave a Reply