.tmux: Cannot get vi-copy working

Created on 14 Dec 2017  路  16Comments  路  Source: gpakosz/.tmux

Hi

vi-mode doesn't work for me, I can go in select mode with C-a enter but then I can only select text with C-space and not with v. What am I missing? I'm using tmux 2.5

tmux support

Most helpful comment

Hello,

As noted in README.md:

If you're a Vim user, setting the EDITOR environment variable to vim will enable and further customize the vi-style key bindings (see tmux manual).

If you don't want to export EDITOR or VISUAL environment variables, you can customize your ~/.tmux.conf.local copy and uncomment the following lines:

#set -g status-keys vi
#set -g mode-keys vi

All 16 comments

Hello,

As noted in README.md:

If you're a Vim user, setting the EDITOR environment variable to vim will enable and further customize the vi-style key bindings (see tmux manual).

If you don't want to export EDITOR or VISUAL environment variables, you can customize your ~/.tmux.conf.local copy and uncomment the following lines:

#set -g status-keys vi
#set -g mode-keys vi

Sorry, forgot to mention that I'm already exporting EDITOR (and VISUAL) in my .bashrc. Now I've just uncommented those lines and restarted tmux but still doesn't work, I have to press C-space to start selecting instead of v

Here's what I have

$ tmux list-keys | grep selection
bind-key    -T copy-mode    C-Space           send-keys -X begin-selection
bind-key    -T copy-mode    C-g               send-keys -X clear-selection
bind-key    -T copy-mode    MouseDrag1Pane    select-pane ; send-keys -X begin-selection
bind-key    -T copy-mode-vi Space             send-keys -X begin-selection
bind-key    -T copy-mode-vi A                 send-keys -X append-selection-and-cancel
bind-key    -T copy-mode-vi v                 send-keys -X begin-selection
bind-key    -T copy-mode-vi MouseDrag1Pane    select-pane ; send-keys -X begin-selection

If you see the following line but you can't use v to select, then your tmux is not in vi mode:

bind-key    -T copy-mode-vi v                 send-keys -X begin-selection

That's strange, I do have that line for the v key but still it doesn't work..

$ export|grep EDI
declare -x EDITOR="vim"
$ tmux list-keys | grep selection
bind-key    -T copy-mode    C-Space           send-keys -X begin-selection
bind-key    -T copy-mode    C-g               send-keys -X clear-selection
bind-key    -T copy-mode    C-w               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode    MouseDrag1Pane    select-pane ; send-keys -X begin-selection
bind-key    -T copy-mode    MouseDragEnd1Pane send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode    M-w               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi C-j               send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi Enter             send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi Space             send-keys -X begin-selection
bind-key    -T copy-mode-vi A                 send-keys -X append-selection-and-cancel
bind-key    -T copy-mode-vi v                 send-keys -X begin-selection
bind-key    -T copy-mode-vi y                 send-keys -X copy-selection-and-cancel
bind-key    -T copy-mode-vi MouseDrag1Pane    select-pane ; send-keys -X begin-selection
bind-key    -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-selection-and-cancel

The strange thing is that even pressing C-w (assuming that I'm in normal copy-mode) it doesn't copy the selected text to the clipboard (I do have xsel installed). I'm using your base .tmux.conf untouched plus few minor customizations in .tmux.conf.local.

Anyway thanks for this repo, your help and sorry for using github's issues as a support forum.

What about

$ tmux show -wg mode-keys
mode-keys vi
$ tmux show -g status-keys
status-keys vi

?

This is weird

$ tmux show -g status-keys
status-keys emacs
$ tmux show -wg mode-keys
mode-keys emacs

and the VISUAL environment variable?

$ export|grep VISUAL
declare -x VISUAL="vim"

Well if you edit ~/.tmux.conf.local, force vi mode, and reload configuration at least show -g should tell you vi

It still says it's in emacs mode. Weird.

Are you sure all tmux server process are killed/restarted?

Oh fsck, you nailed it with the last comment, I had a tmux process running since yesterday...I've killed it and started a new tmux session and now everything works with just the EDITOR/VISUAL export. Sorry for the noise, didn't think about checking this before :( Thanks for your help!

No worry. Have fun

I've also been having the same problem but restarting tmux with kill-server doe not actually work for me, neither does reloading the tmux.conf.

I have this in my .tmux.conf

set-window-option -g mode-keys vi
set -g status-keys vi

Oddly enough, entering set -g status-keys vi into the command prompt allows me to use <C-[> in the command prompt afterward, until i kill-server and restart tmux. Then <C-[> will no longer work again...

@vide do you happen to have the same behaviour when restarting tmux?

Hello @dylan-chong

There are two approaches to debugging your problem:

  1. either vi mode is not enabled, which you can check with
$ tmux show -wg mode-keys
mode-keys vi
$ tmux show -g status-keys
status-keys vi
  1. either bindings are wrong, which you can check with
$ tmux list-keys |grep '\-vi

If tmux-show doesn't tell vi, then likely you didn't restart the tmux server process. Try $ killall tmux?

If tmux-show tells vi but you're experiencing unexpected behavior, then double check the bindings.

You can also launch tmux the following way, which makes sure

  1. you're launching another server
  2. you're not using this configuration
$ tmux -L test -f /dev/null
$ tmux -L test show -wg mode-keys
mode-keys vi
...

Hope that helps.

Thanks for the quick reply.

After some debugging, i found out that the plugin tmux-plugins/tmux-sensible was overriding the status-keys setting when it wasn't supposed to override any user settings at all

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shortspecialbus picture shortspecialbus  路  3Comments

obitech picture obitech  路  4Comments

ww7 picture ww7  路  4Comments

nikolayzhmurov picture nikolayzhmurov  路  5Comments

romanhaa picture romanhaa  路  4Comments