{"slug": "my-nvim-tmux-workflow", "title": "My nvim/tmux workflow", "summary": "The article describes the author's workflow integrating tmux with Neovim for efficient terminal-based development, including custom tmux configurations like remapping the prefix key to `C-p` and enabling Vim-style navigation. It explains how to set up seamless pane navigation between tmux and Neovim splits using the `vim-tmux-navigator` plugin, allowing users to move between panes with the same keybindings. The author also shares a method for tmux to detect whether a pane is running Vim and adjust keybindings accordingly.", "body_md": "My nvim/tmux workflow\nAt my previous employment I was forced to use a windows system. Although not ideal, I was able to continue using my Linux terminal workflows by heavily utilizing Windows Subsystem for Linux. As part of this I had to get comfortable with integrating tmux into my workflow as I didn’t care to learn the Windows Terminal options for terminal multiplexing. I don’t need tmux quite as much anymore since my current employer allows me run Linux on my development machine, but I still use it when remoting into my work desktop via ssh. Hopefully this can be of use in improving the efficiency of others that depend on terminal based workflows.\ntmux setup\nAs a note, all of the below settings should be added to your ~/.tmux.conf\nif you are interested in using them.\nSome nice settings\nI wanted to start out with some nice settings for tmux that I generally like.\nFirst and foremost I remap the send-prefix\nkey.\nunbind C-b\nset -g prefix C-p\nbind C-p send-prefix\nI also rebind the pane splitting commands:\nbind | split-window -h -c \"#{pane_current_path}\"\nbind - split-window -v -c \"#{pane_current_path}\"\nunbind '\"'\nunbind %\nAnd finally, I enable vim key binds in scrolling mode\nset-window-option -g mode-keys vi\nbind-key -T copy-mode-vi v send -X begin-selection\nbind-key -T copy-mode-vi V send -X select-line\nbind-key -T copy-mode-vi y send -X copy-pipe-and-cancel 'xclip -in -selection clipboard'\nIntegration with neovim\nHere by integration, I mean seamlessly transitioning between tmux and neovim splits.\nTo do this we want tmux to figure out if the current tmux split contains a vim process (and potential vim splits).\nWe then can then bind the same motion keys in tmux and nvim so that we can seamlessly move from a tmux split into a vim split and back all using the same keys!\nWe can do this with the following code snippet in our ~/.tmux.conf\n.\nis_vim=\"ps -o state= -o comm= -t '#{pane_tty}' \\\n| grep -iqE '^[^TXZ ]+ +(\\\\S+\\\\/)?g?(view|n?vim?x?)(diff)?$'\"\nbind-key -n C-h if-shell \"$is_vim\" \"send-keys C-h\" \"select-pane -L\"\nbind-key -n C-j if-shell \"$is_vim\" \"send-keys C-j\" \"select-pane -D\"\nbind-key -n C-k if-shell \"$is_vim\" \"send-keys C-k\" \"select-pane -U\"\nbind-key -n C-l if-shell \"$is_vim\" \"send-keys C-l\" \"select-pane -R\"\nbind-key -n C-\\ if-shell \"$is_vim\" \"send-keys C-\\\\\" \"select-pane -l\"\nis_vim\ndefines a command to determine whether the current pane is running vim.\nIf so, we send the key codes directly to vim, otherwise process the key binding with tmux.\nFor this case we utilize <C-{vim_keys}>\nfor motion to make things easy.\nNeovim setup\nNow we need to make sure we can go from a neovim split smoothly to a tmux split. To do this we utilize the christoomey/vim-tmux-navigator plugin. First add it to your plugin manager,\nLazy.nvim:\nrequire(\"lazy\").setup({\n\"christoomey/vim-tmux-navigator\"\n})\nor Vim-plug:\ncall plug#begin('~/.vim/plugged')\nPlug 'christoomey/vim-tmux-navigator'\ncall plug#end()\nand that’s it!\nIt should automatically add the <C-{vim_keys}>\nfor motion and handle moving out of vim splits to tmux panes.\nHopefully this is useful to someone else!\nBonus\nGruvbox is everywhere even tmux gets a nice theme.", "url": "https://wpnews.pro/news/my-nvim-tmux-workflow", "canonical_source": "https://www.alexselimov.com/posts/tmux_and_nvim/", "published_at": "2024-03-05 02:44:00+00:00", "updated_at": "2026-05-23 08:37:06.453323+00:00", "lang": "en", "topics": ["developer-tools", "open-source"], "entities": ["nvim", "tmux", "Windows Subsystem for Linux", "Windows Terminal", "Linux"], "alternates": {"html": "https://wpnews.pro/news/my-nvim-tmux-workflow", "markdown": "https://wpnews.pro/news/my-nvim-tmux-workflow.md", "text": "https://wpnews.pro/news/my-nvim-tmux-workflow.txt", "jsonld": "https://wpnews.pro/news/my-nvim-tmux-workflow.jsonld"}}