1

Im from Linux-Ubuntu: Im new at coding, I started to use VIM to code in PYTHON so ===> is there any way I could select a chunk of code and then with execute it in linux terminal and then with an enter return to VIM. Sorry for my english writing

3
  • looks like you want to make vim your shell Commented Feb 10, 2016 at 20:25
  • 2
    If you're interested in Vim, do check out Vi and Vim! Commented Feb 10, 2016 at 20:50
  • 1
    There's also a QuickRun plugin to quickly run selected text or a file with some command: github.com/thinca/vim-quickrun/blob/master/doc/quickrun.txt Commented Feb 12, 2016 at 20:33

2 Answers 2

3

Select the block of text by pressing V and moving around:

enter image description here

Now use :w !python3 (or python, as the case may be):

enter image description here

This calls python3 and passes the selected text to the standard input. So, if your code makes use of stdin, this won't work well. Naturally, this won't get you far. For running entire files, you can use :!python3 % or :!python %.

Sign up to request clarification or add additional context in comments.

Comments

1

You can do it this way

Go into visual mode in vim press: V

Select the text you want to execute

Type :w test.py ( creating a python script in the folder you're in)

Type :!python test.py

And press enter to return to vim

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.