Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrow keys are not working in tmux #10

Open
sharkvan opened this issue May 15, 2018 · 4 comments
Open

Arrow keys are not working in tmux #10

sharkvan opened this issue May 15, 2018 · 4 comments

Comments

@sharkvan
Copy link

I'm a real fan of this setup. But I also really like tmux. When I run vim now in tmux my arrow keys kick me out of insert mode and print a,b,c, or d on a new line until I hit the ESC key. I'm not sure how to begin to debug this so I can fix it. But I would love it if someone either knows how to fix it or can point me to how I would start to debug it. Just to clarify, everything works fine outside of tmux.

@DamZiobro
Copy link
Owner

could you paste your tmux arrow keys shortcuts from tmux config file here?

@sharkvan
Copy link
Author

This is my tmux config file

# 0 is too far from ` ;)
set -g base-index 1
set -g default-terminal screen-256color
set -g mouse on
set -g monitor-activity on
bind > setw synchronize-panes

# No delay for escape key press
set -sg escape-time 0

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

#Plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

#Continuum Settings
set -g @continuum-restore 'on'

#Vim restore settings
set -g @resurrect-strategy-vim 'session'

#Initialize TMUX plugin manager (Keep this line at the very bottom of the config file)
run '~/.tmux/plugins/tpm/tpm'

And here are all the keys that tmux list-keys reports as being bound to arrow keys.

bind-key    -T copy-mode    Up                send-keys -X cursor-up
bind-key    -T copy-mode    Down              send-keys -X cursor-down
bind-key    -T copy-mode    Left              send-keys -X cursor-left
bind-key    -T copy-mode    Right             send-keys -X cursor-right
bind-key    -T copy-mode    M-Up              send-keys -X halfpage-up
bind-key    -T copy-mode    M-Down            send-keys -X halfpage-down
bind-key    -T copy-mode    C-Up              send-keys -X scroll-up
bind-key    -T copy-mode    C-Down            send-keys -X scroll-down
bind-key    -T copy-mode-vi Up                send-keys -X cursor-up
bind-key    -T copy-mode-vi Down              send-keys -X cursor-down
bind-key    -T copy-mode-vi Left              send-keys -X cursor-left
bind-key    -T copy-mode-vi Right             send-keys -X cursor-right
bind-key    -T copy-mode-vi C-Up              send-keys -X scroll-up
bind-key    -T copy-mode-vi C-Down            send-keys -X scroll-down
bind-key -r -T prefix       Up                select-pane -U
bind-key -r -T prefix       Down              select-pane -D
bind-key -r -T prefix       Left              select-pane -L
bind-key -r -T prefix       Right             select-pane -R
bind-key -r -T prefix       M-Up              resize-pane -U 5
bind-key -r -T prefix       M-Down            resize-pane -D 5
bind-key -r -T prefix       M-Left            resize-pane -L 5
bind-key -r -T prefix       M-Right           resize-pane -R 5
bind-key -r -T prefix       C-Up              resize-pane -U
bind-key -r -T prefix       C-Down            resize-pane -D
bind-key -r -T prefix       C-Left            resize-pane -L
bind-key -r -T prefix       C-Right           resize-pane -R

Thanks for you help.

@henczati
Copy link

henczati commented Jul 12, 2018

+1

I can confirm it on both using a Cygwin terminal on Windows 10 connected to an Ubuntu 16.04.4 server through ssh and a vte console/terminal locally.

The problem exists when trying to move the cursor with the arrow keys in insert mode.

In a plain terminal the arrow keys move the cursor correctly, but they exit insert mode (stays in normal mode).

In tmux the behaviour is similar than when vim is run in vi compatibility mode: in normal mode the arrows move the cursor correctly, but in insert mode they (I guess) exit and reenter insert mode and put a new line just above the last cursor position with a single uppercase letter depending on the arrow key pressed: A (up), B (down), C (right), D (left). I think the letter is the same as in the arrow key's character representation.

This might help: Fix arrow keys that display A B C D on remote shell

Other vim ide configurations I tried (vim-ide by sebdah, yavide) do not have this issue.

I use the default tmux keybindings.
My .tmux.conf:

#set -g default-terminal "screen-256color"
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xsel -i --clipboard"

### This must be at the bottom ###

set -g @continuum-restore 'on'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

@wilhelmloof
Copy link

wilhelmloof commented May 22, 2023

I know this is an old thread, but I just had this issue and solved it by adding set nocompatible to ~/.vimrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants