惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
B
Blog
小众软件
小众软件
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
L
LangChain Blog
WordPress大学
WordPress大学
罗磊的独立博客
GbyAI
GbyAI
S
SegmentFault 最新的问题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
月光博客
月光博客
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
雷峰网
雷峰网
美团技术团队
F
Fortinet All Blogs
Hugging Face - Blog
Hugging Face - Blog
The GitHub Blog
The GitHub Blog

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Vim-like Settings for Tmux
2018-09-30 · via jdhao's digital space

I am a Neovim (or Nvim in abbreviation) user. In Nvim, we use Ctrl-W as prefix for window-related operations. However, the default prefix is Ctrl-B in Tmux. As a result, I often mistakenly press Ctrl-W when trying to change panes inside Tmux, which is annoying. Why not change tmux prefix to be more vim-like?

Tmux does not create a configuration file under your home by default. You have to create one yourself. First, we need to create a config file named .tmux.conf under home directory:

Then, we edit this file to customize tmux behaviours.

Change prefix#

To change prefix, add the following settings to .tmux.conf,

unbind C-b
set-option -g prefix C-w
bind-key C-w send-prefix

Split panes like Vim#

By default, tmux use <prefix> % and <prefix> " to split window vertically and horizontally respectively, which is rather obscure. We can change it to be more Vim-like.

# use <prefix> s for horizontal split
bind s split-window -v
# use <prefix> v for vertical split
bind v split-window -h

Then we can use <prefix> s and <prefix> v to create horizontal and vertical split respectively.

Vim-like pane navigation#

In order to use the traditional Vim navigation key HJKL to switch between different panes, use the following settings:

bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

Then we can use <prefix> h/j/k/l to go to pane left/below/above/right.

We can also use Altand arrow keys for pane switching,

bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

Then we can press Alt followed by arrow key to switch panes.

Resize panes#

# resize panes more easily
bind < resize-pane -L 10
bind > resize-pane -R 10
bind - resize-pane -D 10
bind + resize-pane -U 10

To resize pane in the horizontal direction, use <prefix> < or <prefix> >. To resize pane in the vertical direction, use <prefix> + or <prefix> -.

How to reload tmux config?#

If you are in a tmux session, just press <prefix>, then use command :source ~/.tmux.conf to refresh the Tmux session. If you are outside of a Tmux session, use tmux source ~/.tmux.conf to refresh tmux configurations.

Note: before changing the tmux prefix key, the old prefix still takes effect. If you want to change the prefix inside a tmux session, you need to use the old prefix.

References#