2

It is explained in many places, how to run a python script from vim including Running Python code in Vim.

But my output spans across pages and only I can see the last page. I am not able to move to top of the results.

I tried :!clear;python % | more. This will keep the output in more, but once more is exited, things are same. Any ways to move in the result pane?

Also I not able to add the shortcut "map :w:!python %|more".

6
  • try reading this askubuntu.com/questions/273066/running-python-in-vim Commented Apr 16, 2016 at 18:09
  • @PetarP: %pyf is very much similar to ;python % | more. It also does not accept raw_input. Giving an error " count = raw_input('Enter Count -') EOF \n Error: EOF when reading a line " Commented Apr 16, 2016 at 19:37
  • Here is a official vim documents, this first part should handle your error, vim.wikia.com/wiki/Execute_Python_from_within_current_file Commented Apr 16, 2016 at 19:46
  • I would use :new followed by :r !command, but I'm sure there's a way to avoid the :new if you know what you're doing (I don't). Commented Apr 16, 2016 at 22:14
  • Just run your code in another shell. Commented Apr 17, 2016 at 6:47

1 Answer 1

0

The output is simply printed out into your terminal, so you should use terminal's capabilities to scroll. Both Linux TTY and many X11 terminal emulators support Shift-PgUp/PgDown; in X11, you can also use scrolling wheel if that's your thing.

If you need to process the output using Vim, you should prefix your ! with read: :read !python %; that will put the output into the current buffer.

Also I not able to add the shortcut "map :w:!python %|more".

It's better to ask only one question per post. What you're missing in your command is the key you're binding the command to; you should also escape % and |.

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

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.