Vim+TmuxMaster

Hands-On Tmux Guide

Master terminal multiplexing for seamless workflow management

Sessions & Windows

Tmux organizes your work into sessions (collections of windows) and windows (views into shells).

Session Management

tmux new -s name Create a new named session
tmux ls List all sessions
tmux attach -t name Attach to an existing session
tmux kill-session -t name Kill a session

Prefix Key

All tmux commands are prefixed with:

Ctrl+b (Default prefix key)

Window Management

Prefix + c Create a new window
Prefix + n Next window
Prefix + p Previous window
Prefix + number Go to window #
Prefix + , Rename window
Prefix + & Kill window

Interactive Demo: Managing Sessions

terminal
$ tmux new -s project
0:bash* 1:vim 2:server
"project" 3 windows
# This is a tmux session with multiple windows
# Press Prefix + c to create a new window
# Press Prefix + 1 to go to window #1
$ tmux detach
$ tmux ls
project: 3 windows (created Mon Feb 24 10:45:33 2025)
$ tmux attach -t project

Pane Management

Panes allow you to split your tmux windows into multiple viewports, each running its own command.

Creating Panes

Prefix + % Split vertically
Prefix + " Split horizontally

Navigating Panes

Prefix + arrow key Move to pane in that direction
Prefix + o Go to next pane
Prefix + ; Toggle between panes

Resizing Panes

Prefix + Ctrl + arrow key Resize pane by 1 cell
Prefix + Alt + arrow key Resize pane by 5 cells
Prefix + z Toggle pane zoom

Managing Panes

Prefix + x Close current pane
Prefix + { Move pane left
Prefix + } Move pane right

Interactive Demo: Pane Layout

tmux
$ vim app.js
/* Editing code in Vim */
$ git status
On branch main
Changes not staged for commit:
  modified: app.js
$ npm test
PASS src/app.test.js
All tests passed!
[Prefix + " and Prefix + % to create this layout]

Customization & Keybindings

Tmux is highly customizable through its configuration file, allowing you to personalize your workflow.

Configuration File

Tmux reads its configuration from ~/.tmux.conf

Common customizations include:

  • - Changing prefix key
  • - Setting colors and status bar
  • - Modifying keybindings
  • - Setting pane/window options

Sample Config

# Remap prefix from 'C-b' to 'C-a'
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# Reload config with r
bind r source-file ~/.tmux.conf

Visual Customization

# Status bar customization
set -g status-style bg=black
set -g status-left '#[fg=green]#S '
set -g status-right '#[fg=cyan]%b %d %H:%M'

# Highlight active window
set-window-option -g window-status-current-style bg=red

# Set active pane border color
set -g pane-active-border-style fg=cyan

Mouse Support

# Enable mouse mode (tmux 2.1+)
set -g mouse on

# In older versions:
# set -g mode-mouse on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on
# set -g mouse-select-window on

Before/After Customization Example

Default Tmux

0:bash* 1:vim "session" | Feb 24 10:45
Default tmux status bar and styling

Customized Tmux

bash vim server vim-tmux-demo | 󰃰 80% | Feb 24
Custom-styled tmux with enhanced UI

Take Your Tmux Skills Further

Tmux Power Tools

Advanced Tmux Usage

  • Pair programming with tmux -S /tmp/shared and permissions
  • Create project startup scripts with tmuxinator
  • Learn custom layouts with select-layout command
  • Master command mode with Prefix + :

Ready to see how Vim and Tmux work together in real-world scenarios?

Explore Workflow Examples →