13

I have been playing with tmux and I'm loving it. However, there's an annoying issue when running vim inside it.

Somehow the arrow keys get remapped, but only on certain times, like when firing up Command-T, if I try to scroll down the file list, the command is cancelled and I'm thrown into insert mode, and depending on the arrow key I pressed, an A, B, C, or D is inserted.

If I use the arrows to move through a buffer for example, they work properly.

Any ideas?

Thanks!

Ivan
  • 4,679

6 Answers6

15

I simply added set -g default-terminal "xterm" to my .tmux.conf

This made tmux use xterm instead of screen, so life is beautiful and I don't need to worry about stomping on keybindings.

Zee
  • 425
7

Finally I found my answer here: when running screen on OSX, command+r messes up arrow keys in vim across all screens

The weird thing is I only added ONE mapping to my .vimrc file:

map <Esc>[B <Down>

But that single mapping makes ALL the arrow keys work properly...

Ivan
  • 4,679
1

The xterm and xterm-256color causes the BCE problem. See http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1932.

1

Just in case someone happens to get mad with this solutions not working.

Check out that you don't are actually using tmux + vim + AutoClose vim plugin. Autoclose maps something that causes you having ABCD chars inserted in the previous line!

I just erased the plugin and it's working alright now

txomon
  • 147
  • 5
0

Command-T does something dumb by mapping when running in a terminal. It skips the mapping if $TERM is vt100* or xterm*, but that's not a good solution.

graywh
  • 197
0

For those people that want to move the cursor in command line mode, take a look at this blog post. I ended up adding eight lines in my vimrc;

" Needed for tmux and vim to play nice
" Needed for tmux and vim to play nice
map <Esc>[A <Up>
map <Esc>[B <Down>
map <Esc>[C <Right>
map <Esc>[D <Left>

" Console movement
cmap <Esc>[A <Up>
cmap <Esc>[B <Down>
cmap <Esc>[C <Right>
cmap <Esc>[D <Left>
frbl
  • 101