Running Python in Vim

Running Python in Vim

I have tried Googling but I couldn't find anything relevant.

Is it possible to program in Python on VIM and do something like

:!iPython

to have Python execute the code?

Last time I tried that, it just opened up Python in the terminal.

2 Answers

Save the current buffer with :w, then :!/usr/bin/env python %.

10

or even better set aw in your .vimrc, follow by

:pyf %

this will not incur you to bring up shell and hence better.

if you want you can map it and save in your .vimrc following cmd

map <F8> pyf %<CR>

hitting F8 will execute your python file

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.