1

When I write python script in VIM I would like to test them into VIM directly I know that I can use:

w !python -

But this execute the script and suddenly close the shell so if I want to test a function I can't call it with various arguments! For example if I have this code:

print "How can I test the following function in Vim?"
def testfunc(test):
    print test*2

When I run in VIM w !python - it print me the print statement but I can't try to test the function with some arbitrary arguments. How can I run the script in a python shell for further testing?

2 Answers 2

2

You can run a Python script and then immediately switch to interactive mode with the -i flag:

python -i test.py
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect now i use :!python -i %and it works great! Thanks a lot!
0

You may run interactive buffer like Conque Term with python commandline and then just import your .py file in it.

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.