First off, I'm aware that I can use Alt+1 (through 9 and 0) to synthesize the respective function keys (F1 through F10) in Midnight Commander. It has helped me many times, but by default I still press the actual function keys intuitively.

Gist: I'm trying to run both Vim and Midnight Commander inside a tmux session (sometimes window, sometimes pane), using PuTTY.

So by default I have the following PuTTY configuration:

PuTTY keyboard config

With ESC[n~ mapping

The problem now when mapping (map <F1> :tab help<CR>, and also nmap and imap) F1 in Vim, is that it gives the effect of ~ (toggle case). And indeed if I press F1 through F5 in the shell, the tilde (~) is the result, along with a bell. The function keys work perfectly fine in Midnight Commander, though, using this setting.

There is one odd thing about the above setting in addition to my problems with F1: I also "mapped" F5 (set pastetoggle=<F5>) in Vim. Strangely enough that works like a charm, even though the F5 key on the shell gives a ~ just like F1 etc.

Note: when running Vim outside of tmux, the default binding (and my override) of F1 work fine!

With "Linux" mapping

So naturally I tried to use the "Linux" setting in the dialog above. So when I press F1 Vim goes into insert mode at the end of the line (effect of A). Midnight Commander doesn't recognize any of the function keys with this setting. Sure enough on the shell F1 gives me A and a bell (F2 a B and so on).

What am I missing here? How can I get a uniform behavior where both Midnight Commander and Vim will recognize the function keys?

Additional info:

Remote system is Ubuntu 14.04 with LANG=en_US.UTF-8.

TERM is set to TERM=xterm outside the tmux session and TERM=screen when seen from inside a pane or window.

I am not using:

set-option -g default-terminal "screen-256color"

to override the terminal type inside tmux.

1 Answer 1


The problem is the TERM=xterm outside tmux. There is no configuration of PuTTY which matches the xterm terminal description, and the mismatch feeds into screen or tmux (take your pick).

See for example, in the ncurses FAQ Why not just use TERM set to "xterm"?. The recommendation there is of course to set


A quick check using tack shows that this combination (TERM=putty, tmux) works for Ubuntu 14.04 (you should have installed the ncurses-term package, which includes this).

  • Thanks. Actually I couldn't find tack at all, not with apt-file search nor after installation of the package you recommended. But toe -a|grep -i putty confirms that several PuTTY terminal definitions exist (including a putty-256color). I'll try it out and get back to you and also accept accordingly. May 23, 2015 at 20:17
  • I hadn't noticed that tack wasn't in Ubuntu 14.04 (it's been in Debian a while, but probably overlooked when I split it out of the ncurses source tarball). Checking my machine, it looks like I was running one of my packages. May 23, 2015 at 20:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .