Alright, full disclosure, I did not learn this today but I did use it today and almost every other day, so I decided to write about it anyway. I use Vim and Tmux (unfortunately, I am actually a bit embarrassed for both of those websites - remember they are great tools, with or without great websites). I also use splits in both. Moving around can be a bit tricky when you have one set of shortcuts to use when jumping between Tmux panes and a separate set of shortcuts to use when jumping between Vim panes.
By default moving your cursor from pane to pane in Vim uses
<C-w>) followed by
l to move left, down, up or right respectively. I find it simpler to use
Control followed by
l. That is a pretty simple thing to configure Vim to do:
That works great, however I want to take it to the next level. When I try to move down a pane and there are no more vim panes below my current pane but there is a tmux pane I want it to automatically jump down into the tmux pane. This is a bit more tricky, but can be handled with a function added to our
.vimrc file and remapping our keys to use the function.
In Tmux, moving your cursor between panes is different. The primary one I use is
<Leader>-o. Unfortunately, that will just scroll your cursor from pane to pane counterclockwise one pane at a time, which is not quite as nice as moving left, down, up and right. The alternative is using
<Leader-q> will display a number on each pane. Pressing one of the displayed numbers will move your cursor to that pane. That is fine, but I prefer to use something that works the same way as moving between Vim splits. Adding the following mappings in your
.tmux.conf file will enable the same type of moving using
Control followed by
l between tmux panes.
Again, that works great, however I want to take it to the next level. I want a smooth transition moving from tmux pane to vim pane and back. Thanks to all of the hard work of @JarrodCTaylor on the dotfiles (throw him a github star or six - he has earned it) it is possible to do just that. The last little bit of configuration to make it work goes in
Here is a quick video of jumping around between Vim and Tmux splits interchangeably using only
Somewhere, something incredible is waiting to be known. - Carl Sagan