0

When editing a script in vim, I can run it with :! bash % or :! python % for python scripts. When running the script, vim kinda goes back to the terminal, runs there, and then, after "ENTER" it goes back to the Vim window.

I would like to have it open a small window, that I can jump to and from, for execution. Something like:

  1. split window (let's say 1/3 height)
  2. run the script there

Is it possible? (splitting the window is easy, but running the script in said window - not that easy)

2 Answers 2

3

This is what the :terminal command is for:

:terminal bash %
:terminal python %
1
  • Wow. Simpler than I thought. Thx! I think I'm going to map this to something like CTRL+e[xecute] and CTRL+SHIFT+e[xecute] Feb 9 at 7:08
2

One way to have this kind of behaviour is to use tmux to split the terminal into 2 (or more) panes. Then run vim in one of them, and python (or whatever) in another and use a plugin such as vim-slime to send code from vim to the other tmux pane:

enter image description here

1
  • Thought of tmux, but wasn't aware of vim-slime. Thanks. Will check it out! Feb 3 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.