Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
  tmux
  vim test

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

share|improve this question
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
    
Fixed! Thanks @DanielBeck –  Clustermagnet Apr 10 '12 at 17:37
    
Ctrl+H doesn't work for me =/ still gives same ^? –  holms Aug 1 '13 at 20:54

4 Answers 4

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.

share|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).

share|improve this answer

I made a workaround

  1. make an alias in .alias

alias emacs(or vi)='stty erase "^H"

emacs'

2 make a shell script,

filename tmuxsh

stty ek
cmd=$(which tmux)      # tmux path
session=$1
if [ $# = 0 ]; then
   $cmd ls
   exit 0
fi
$cmd has -t $session 2> /dev/null
if [ $? != 0 ]; then
     $cmd new -s $session
     exit 0
fi
$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

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

I find giving this command

stty erase Ctrl-V BACKSPACE

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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