Navigation LazyVim + Terminal + Tmux with Ctrl + h/j/k/l #4899
cittadhammo
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
(this was written by Gemini after our session)
If you find yourself constantly jumping between Neovim splits and Tmux panes, you’ve probably realized that using two different sets of shortcuts is a massive friction point.
The goal is to use
Ctrl + h/j/k/lto move everywhere—regardless of whether you are inside a Vim split or a terminal pane. Here is how to set up seamless navigation using the gold-standardvim-tmux-navigatorplugin within a LazyVim environment.1. The Neovim Side (LazyVim)
LazyVim makes plugin management easy. Create a new file at
~/.config/nvim/lua/plugins/tmux-navigation.luaand add the following configuration. This installs the plugin and maps the keys:2. The Tmux Side
Next, we need to teach Tmux how to "check" if the current pane is running Vim. If it is, Tmux sends the keypress to Vim; if not, Tmux handles the pane movement itself.
Add this to your
~/.tmux.conf:3. Why This Is Better
Ctrl-lalways moves you to the right, whether it's another code file or a running server in a terminal pane.Ctrl-bfirst. It’s a single-action movement.fzfandviewmode as well, so you don't get stuck in those windows either.💡 Pro Tip: Regaining "Clear Screen"
Because we remapped
Ctrl-l(which usually clears the terminal), you can add this to yourtmux.confto clear the screen usingPrefix + Ctrl-l:All reactions