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 foo@bar.com
  vim test

Backspace works fine above.

This doesn't however:

  ssh foo@bar.com
  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 '12 at 17:13
  • Ctrl-H does work! :) Let me read ;) thanks! – Clustermagnet Apr 10 '12 at 17:28
  • Unfortunately im using iterm2 :) – Clustermagnet Apr 10 '12 at 17:29
  • Ctrl+H doesn't work for me =/ still gives same ^? – holms Aug 1 '13 at 20:54

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.

| improve this answer | |
  • 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 '13 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).

| improve this answer | |

I find giving this command

stty erase Ctrl-V BACKSPACE

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

| improve this answer | |

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 a emacs alias in step1? 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

| improve this answer | |
  • Why didn't you just copy/paste the answer instead of making me follow a link? – Wes Sayeed Sep 19 '14 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.