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".

Community
  • 1
  • 1
user2647717
  • 119
  • 1
  • 9
  • try reading this http://askubuntu.com/questions/273066/running-python-in-vim – copser Apr 16 '16 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 " – user2647717 Apr 16 '16 at 19:37
  • Here is a official vim documents, this first part should handle your error, http://vim.wikia.com/wiki/Execute_Python_from_within_current_file – copser Apr 16 '16 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). – o11c Apr 16 '16 at 22:14
  • Just run your code in another shell. – romainl Apr 17 '16 at 06:47
  • I found a better way to run the python from the vim. This will display the output into a new window, where you can use vim commands to search, replace and so on. http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window – user2647717 Apr 26 '16 at 16:20

1 Answers1

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 |.