Tmux and Vim

Written on August 15, 2020

Tmux is one of the most useful applications to use on Linux, and if you read my last post, you know how to get Tmux up and running on Windows too. As a VIM user (addict), I need to use the VIM keys everywhere possible, and in this post, we will configure Tmux to do exactly that.


If you are already experienced with Tmux, you can grab my config files here (otherwise keep reading):

The final product:



You will need Tmux installed and working.

Linux: Install as you would any other package

# Example for Debian based distros
sudo apt install tmux

Windows: Follow the guide in my previous post and then continue from here.


This guide will do more than just add VIM keys to Tmux; it will change the default Tmux prefix Ctrl + b to the backtick `. Additionally, the new configuration references some useful Tmux plugins (we will install these in this guide).

I would recommend backing up your existing Tmux.conf file before continuing:

# Backup your existing config if necessary
cp ~/.tmux.conf ~/.tmux.conf-backup

Set the tmux.conf file

I have a pre-set Tmux.conf file stored as a Gist in GitHub for Linux and Windows.


Here is the link for the Linux Tmux config.

Run the following to quickly install it on Linux (or copy it manually).


# Backup the existing tmux.conf if it exists before overwriting
if [ -f $TMUX_CONF ]; then
  cp $TMUX_CONF ~/.tmux.conf.bak_CodeAndKeep


Here is the link for the Windows Tmux config.

Run the following to quickly install it on Windows (or copy it manually).

NOTE: You will need to be in a bash shell on your WSL Distro


# Backup the existing tmux.conf if it exists before overwriting
if [ -f $TMUX_CONF ]; then
  cp $TMUX_CONF ~/.tmux.conf.bak_CodeAndKeep

Install Tmux plugins

The Tmux configuration file we just installed references some plugins. The configuration will still work without installing them, but I would recommend installing them. More details to follow about how to use them.

# Download TPM (Tmux plugin manager) from github
git clone ~/.tmux/plugins/tpm

You now have the Tmux plugin manager that allows for easy plugin installation. Next step is to launch Tmux, and install the plugins referenced in the config file.


Press ` + I to install the plugins. It will indicate when the install is completed.

If you see an error code 127, ensure you cloned the tmux-plugins/tpm repo to the correct directory (steps above).

At this point, the configuration is completed. The rest of the guide will explain the changes.

What’s New

The Prefix:

Most importantly, the prefix is now the backtick ` (instead of the default Ctrl + b).


Split panes vertically: ` + | (backtick + pipe)

Split panes horizontally: ` + - (backtick + minus)

Move to pane:

  • Up: ` + k
  • Down: ` + j
  • Left: ` + h
  • Right: ` + l

Resize pane:

  • Up: ` + K
  • Down: ` + J
  • Left: ` + H
  • Right: ` + L


Create a new window the same way: ` + c

Cycle through windows:

  • Left: Ctrl + h
  • Right: Ctrl + l

Copy Mode:

Get into copy mode as usual: ` + [

Use the VIM navigation keys while in the buffer.

Begin text selection: v

Yank text selection: y

(with the Tmux-yank plugin, this will also copy the selection to the system clipboard)


Tmux Yank: As indicated above, when copying text from the copy-mode buffer, the text will automatically be copied to the system clipboard.

Works on Linux and Windows (WSL); very useful.

Tmux Resurrect: Provides the ability to save and restore tmux sessions. Even after a reboot or crash.

It will save all panes and windows (in order) and even certain programs that are running in said panes.

Save session: ` Ctrl + s

Press the prefix first, then Ctrl and s keys together.

Restore session: ` Ctrl + r

Press the prefix first, then Ctrl and r keys together.


There are several changes to the default appearance of Tmux using this config.

The most significant is the status bar being on top of the window. As for the other changes, you can see them.

You can always read through the tmux.conf file for comments on all changes, and tweak as needed.

Thanks for reading

PS> exit