I'm having a strange problem:

When sshing into a particular host (from OSX to RHEL5), vim seems to forget how to backspace, but only in a tmux session, ie:

  ssh [email protected]
  vim test

Backspace works fine above.

This doesn't however:

  ssh [email protected]
  vim test

Hitting backspace in insert mode produces ^? What could the problem be?

  • 1
    Does pressing Ctrl-H work? If so, check out this setting (focused) in Terminal.
    – Daniel Beck
    Apr 10, 2012 at 17:13
  • Unfortunately im using iterm2 :) Apr 10, 2012 at 17:29
  • Ctrl+H doesn't work for me =/ still gives same ^?
    – holms
    Aug 1, 2013 at 20:54

6 Answers 6


You might need to change your Terminal to send ^h when you type Backspace.

In Terminal's preferences, the setting is part of the profile, so you can set up a dedicated profile for your SSH connection to that RHEL5 system.

  • and how to change terminal in TMUX? i'm cygwin now and actually in cygwin this works fine, ssh'ing to rhel6.4 vim gives this problem, fixed term in vimrc, problem fixed, but in tmux it's still gives me the same problem
    – holms
    Aug 1, 2013 at 20:55

You can map the backspace key to what you need, like Kevin said. It looks like you need to map it to ^? (rather than ^H)

To do that, use the following command:

stty erase "^?"

This can be added to your startup scripts (.login or .tcshrc or .bashrc, or other files, depending on which shell you use).


To fix backspace on Apple M1 Pro OSX 12.4 I had to do this

$(brew --prefix)/opt/ncurses/bin/infocmp tmux-256color > ~/tmux-256color.info
tic -xe tmux-256color ~/tmux-256color.info





I find giving this command

stty erase Ctrl-V BACKSPACE

works for me. However, I need to do this on every pane.


I made a workaround

  1. Make an alias in .alias

    alias emacs(or vi)='stty erase "^H"
  2. Make a shell script

    # filename tmuxsh
    stty ek
    cmd=$(which tmux)      # tmux path
    if [ $# = 0 ]; then
       $cmd ls
       exit 0
    $cmd has -t $session 2> /dev/null
    if [ $? != 0 ]; then
         $cmd new -s $session
         exit 0
    $cmd att -t $session
    exit 0

Of course, you could make an alias too, alias tm=tmuxsh. then you could use emacs/vi both in tmux or out of tmux well.

Why make an emacs alias in step 1? Because if just use step 2, after quit tmux to normal shell, the emacs/vi will encounter the issue too.

It works well for me.


If you are using xshell like me,try to change Backspace from [Backspace(Ctrl+H)] to [ASCII 127(Ctrl+?)]. In my case, backspace works again in both bash\zsh\tmux+zsh. This problem has nothing to do with $TERM variable.


You must log in to answer this question.

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