Vim and Neovim navigation
How the keys work
Section titled “How the keys work”| Key | Direction |
|---|---|
| Ctrl-h | Left |
| Ctrl-j | Down |
| Ctrl-k | Up |
| Ctrl-l | Right |
Outside Vim/Neovim, bmux takes these keys to navigate panes. By default they do not reach other programs, including fzf and your shell, so Ctrl-l will not clear the shell. List programs that should get them too in the config file, and unbind a key to give it back everywhere:
When Vim or Neovim is the foreground application, bmux forwards the keys to the
editor. Editor split navigation needs mappings. To cross from an editor edge
into a bmux pane, the mapping must call bmux focus DIRECTION.
The mappings below first try an editor split. If focus did not move, they ask bmux to move to a neighboring pane. They also work in tmux. Install one recipe in your editor configuration; no plugin manager is needed.
On Neovim, nvim-bmux-navigator packages the Neovim recipe as a plugin for lazy.nvim, with an option to stay in a zoomed pane.
Moving focus out of a zoomed pane unzooms it. To keep it zoomed instead, have
the mapping run bmux zoomed first: it prints true when the calling pane’s
window is zoomed and false otherwise, and changes nothing. It needs the same
pane variables as bmux focus, described under Pane information.
Ctrl-a arrows, a click, and Ctrl-a o navigate bmux panes directly, including while an editor is running. Moving to another pane while zoomed unzooms first, like tmux.
Neovim
Section titled “Neovim”Add this to init.lua. It uses vim.system, available in Neovim 0.10+,
and maps normal mode only. Keep bmux on the editor’s PATH.
Add this to .vimrc. It maps normal mode only and uses system() to call
bmux or tmux when the editor cannot move farther in that direction.
Pane information
Section titled “Pane information”bmux sets these variables in each pane:
| Variable | Value |
|---|---|
BMUX_SESSION |
Session name when the pane started |
BMUX_SESSION_ID |
Session identifier; unchanged by renames |
BMUX_PANE |
Pane identifier |
bmux focus left, right, up, or down reads these variables to move from
the editor’s pane. Run it inside a bmux pane. With no neighbor in that direction,
focus stays put, except that left from the leftmost pane moves into the
sidebar when it is shown. These variables identify the pane; they are not
configuration options to set yourself.
Backspace and troubleshooting
Section titled “Backspace and troubleshooting”- If Backspace moves focus, configure the terminal to send DEL (
0x7f). ASCII BS (0x08) is indistinguishable from Ctrl-h. - If navigation stops at an editor edge, confirm the mapping is loaded and
bmuxis on the editor’sPATH. - To check the bmux side without a mapping, run
bmux focus rightin a pane with a neighbor on its right, andbmux zoomedafter zooming with Ctrl-a m. - Use Ctrl-a arrows or Ctrl-a o when you want to bypass editor mappings.