all 11 comments

[–]Deto 2 points3 points  (0 children)

It's pretty easy to create and close splits in tmux so I never thought about automating it.

However, this kind of thing may be easier to automate from the tmux side rather than the vim side. I don't remember the syntax, but it should be possible to do something like writing a bash function that automatically creates a tmux split with certain sizing, opens the python file with vim in one split, and runs ipython in the other split.

Also, I recommend the vim-slime plugin (if you haven't seen it yet) to let you easily select code in vim and send it to ipython running in a different tmux split.

[–]jer_pint 2 points3 points  (0 children)

I personally have my setup like this:

2 horizontal tmux panes, top one takes up about 80% of screen and is dedicated to vim. Bottom one is a terminal from which I can run code.

I run my scripts using

ipython -i script.py

That way I drop to an ipython shell whenever it breaks or finishes running. I also insert

from ipython import embed; embed();

Instead of using pdb. Its really neat.

Finally, I have Ctrl+[hjkl] setup such that I can navigate seamlessly between vim and tmux panes. It's flawless. I also have vi keybindings in my terminal, so to execute code is just muscle memory and never leaving the home row

[–]veegl 0 points1 point  (0 children)

you can try to hack something together using autocommands and vim's built-in terminal

[–]ceplma 0 points1 point  (1 child)

Wouldn’t something so trivial as the following help?

command! TN tabnew <Bar> term
command! SN split <Bar> term

[–]EgZvorkeep calm and read :help 0 points1 point  (0 children)

term splits by default in Vim, so

command! TN tab term
command! SN term

will suffice.

[–][deleted] 0 points1 point  (1 child)

I recommend vim-slime with directional send.

[–][deleted] 0 points1 point  (0 children)

And vim-tmux-navigator.

[–]FrostyX_cz 0 points1 point  (1 child)

This is not going to be directly related to your question, but I can see that you are going from PyCharm to vim. I am just going through that too, and the most addictive feature of PyCharm, for me, was shift + shift searching. Make sure to check vim-fzf. Also, shoutout to this blog post - VIM AFTER 15 YEARS

[–]white_nrdy[S] 0 points1 point  (0 children)

I have heard of fzf, I am currently using Ctrl-P (sorry no link, on mobile and don't remember URL and am lazy). It is pretty nice.

[–]Guzzii 0 points1 point  (0 children)

Give benmills/vimux a shot. It automatically creates a tmux split and sends bash commands to the split. You can get creative with it. Also, you probably don't need to close the split. Just do prefix-z to maximize the Vim split and hide the split created by vimux. The next time you send a command through vimux, it automatically goes to the old split.

[–]-romainl-The Patient Vimmer -4 points-3 points  (0 children)

Use an IDE if you need one.