Sal's

vim-tmux-navigator is magic

As I've mentioned a few too many times, I've been cavorting in the terminal. I'm learning a lot and having a ball.

One recent discovery I'm pretty thrilled about is christoomey/vim-tmux-navigator, which lets you seamlessly move between Tmux panes and Vim/Neovim windows as if they were part of the same app.

Suppose I have this situation happening in my terminal:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (1)                 β”‚ (3)      β”‚
β”‚                     β”‚          β”‚
β”‚ Neovim buffer #1    β”‚   Shell  β”‚
β”‚                     β”‚          β”‚
β”‚                     β”‚          β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ (2)                 β”‚ (4)      β”‚
β”‚                     β”‚          β”‚
β”‚ Neovim buffer #2    β”‚   smrrj  β”‚
β”‚                     β”‚          β”‚
β”‚                     β”‚          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Boxes 1 and 2 are windows in the same Neovim instance, which is inside one Tmux pane. Box 3 is a second Tmux pane running my fish shell. Box 4 is a third Tmux pane running smrrj. I haven't invented smrrj yet but I can tell it's gonna be good.

With vim-tmux-navigator, I can move across these four boxes with the same four keybindings. Ctrl-h moves to the left, Ctrl-j moves down, Ctrl-k moves up, and Ctrl-l moves to the right. (If you're not familiar with Vi/Vim, the hjkl keys perform the basic movements in those same directions.) It doesn't matter if I'm moving from a Neovim window into another Neovim window, or moving out of Neovim into a another Tmux pane, or back into Neovim.

It's not magic. It's actually pretty easy to understand how it works, even for my smoothbrain. But it feels like magic.

Before vim-tmux-navigator, I had one set of keybindings to move across Neovim windows, and another set to move across Tmux panes. For example, Ctrl-w l moved me to the right in Neovim, but Ctrl-Space l moved me to the right in Tmux. It tripped me up constantly.

Cheers to Chris Toomey for maintaining this repo. Judging by its nearly 6,000 stars, I'm not the only happy user!