I just set up IDE env for Python 3. I was wondering how I can run the file being currently edited in vim. I remembered that the command was “:python %”, but it did not work for Python 3.
Thank you very much.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For Python 3, just simply execute
:!python3 %Furthermore, you might also want to map it to a hotkey in your settings, like what I did:
noremap <D-r> <esc>:w<CR>:!python3 %<CR>So that you can just press
Command+rto execute the current code with Python 3 anytime (it will be saved automatically.