Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 154090 - Problems with vim7 and backspace
Summary: Problems with vim7 and backspace
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Vim Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-04 17:55 UTC by Lluís Batlle i Rossell
Modified: 2011-10-05 07:19 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lluís Batlle i Rossell 2006-11-04 17:55:54 UTC
Hi,

when I upgraded my vim6.4 to vim7, I found that my backspace key didn't work fine inside vim. I use xterm, and xterm sends ^? on BS. 'stty' is configured for ^? also. But vim gets configured to ^H. I can see that with ":set t_kb" in vim.

After dealing a long time with it, with irc help from "tpope" of #vim@freenode, we found that the option causing the problem is "set esckeys", run by default in no-compatibility mode.

I've tried compiling 'vim7' from www.vim.org, and applying all the patches until 158, and the problem still appears.

My solution is disabling 'esckeys' by now in my vimrc, but sure there is a problem in some other place.
I've just recompiled ncurses to 5.5, and the problem remains.

Reinstalling vim 6.4 makes everything work, but that isn't 7.0. Ah, I use UTF-8 everywhere.
Comment 1 Mike Kelly (RETIRED) gentoo-dev 2007-01-11 15:46:59 UTC
Hmm, the backspace key works fine for me in a plain xterm. I'm using LANG and LC_ALL="en_US.UTF8"

While in insert mode, it removes the previous character, as expected. Otherwise, it just moves the cursor back by one character. Are you still having problems with this using the gentoo ebuilds?

Hmm, looks like my xterm is set to do: erase = ^H;

So, I'm wondering why yours is using a different erase character. Maybe you're on a non-US layout keyboard or something?
Comment 2 Lluís Batlle i Rossell 2007-01-11 16:06:14 UTC
(In reply to comment #1)
> Hmm, the backspace key works fine for me in a plain xterm. I'm using LANG and
> LC_ALL="en_US.UTF8"
> 
> While in insert mode, it removes the previous character, as expected.
> Otherwise, it just moves the cursor back by one character. Are you still having
> problems with this using the gentoo ebuilds?
I've not tried the newer ebuilds, but the vanilla vim7 code did the same. I've not tested it again since my post here, and I've kept using 6.4.
> 
> Hmm, looks like my xterm is set to do: erase = ^H;
I've tried in the xterm in my workplace (not at home), and there is also ^? there. And there I use 'us' layout, with locale en_US.ISO-8859-1.
> 
> So, I'm wondering why yours is using a different erase character. Maybe you're
> on a non-US layout keyboard or something?
Sure. At home I use concretely "es+eo,ru", where 'eo' are addon keys for esperanto.
I have LANG="ca_ES.UTF-8" and LANGUAGE="ca_ES:ru_RU:es_ES".
Comment 3 Lluís Batlle i Rossell 2007-02-26 22:10:21 UTC
I found the problem!

There are several things affecting:
- termcap definition (^H)
- stty (^? in my case, which vim7 seemed to ignore, I don't know why)

stty was determined in xterm by:
- backarrow* respources (affected by xterm compilation flags),
- *VT100.Translations resource
- *ttyModes resource

In my system there was VT100 and ttyModes resources set:
*VT100.Translations: #override \
   <Key>BackSpace: string(0x7F)
*ttyModes: erase ^?

The first makes xterm send ^?, and the second makes xterm configure stty with ^? for erase.

This should make vim work, but it didn't in my system. Only vim6.4 with the gentoo patches or configure parameters worked (I still don't know why). Vim 7 also from gentoo didn't work.

Any vim6.4 or vim7 vanilla also didn't work. I guess there's something broken with vim and stty in my system, but I don't know what.

My solution was removing named the resources, and leave everything on default, with ^H in xterm. I don't remember why I ever set ^? for xterm.

If I find why vim fails on stty, I'll let know.
Comment 4 Lluís Batlle i Rossell 2007-02-26 22:56:06 UTC
Further investigation showed that the problem is in _xterm_.

vim, detecting an xterm, asks the xterm version. Look at may_req_termresponse(). This is run only if "esckeys" is enabled - which in turn is logical according to the first analysis in #vim at irc.

xterm, sending its version, sends some terminal commands, between them, overwriting the "backspace" to ^H, although it's configured for ^?.

I'll try to look at the xterm code where this thing is bad.
Comment 5 Lluís Batlle i Rossell 2007-02-26 23:36:15 UTC
Ok, I found the bug in xterm!

When vim asks the xterm for the "backspace" character using a DCS request,
xterm answers _always_ ^H.

This is in the line input.c:770 of xterm version 222. There's hardcoded:
on a termcap request, if the key asked is backspace, return "8" (that is, ^H). That's completely _hardcoded_, regardless of the xresources configuration.
Comment 6 Mike Kelly (RETIRED) gentoo-dev 2007-04-10 04:41:59 UTC
Sorry, Lluís, but I think I'm out of suggestions. This is a bug with the source code of the package, so I'd suggest you send a message to the vim-dev mailing list and folks will be able to help you better there. When Bram releases an official patch, I'll include it in Gentoo.

See http://www.vim.org/maillist.php for more info on posting to vim-dev.
Comment 7 Lluís Batlle i Rossell 2007-04-10 08:12:30 UTC
I already notified the xterm developer, as the problem isn't in vim.
He acknowledged the problem, and said that he will look for a way to fix it.

Thank you for your attention!
Comment 8 a 2011-10-05 07:19:40 UTC
For anyone who gets here (as I did) via google, some places still have this issue. I have been using one such place pretty heavily, alas.

Good workaround if you can't/don't want to install a new version of xterm or whatever is to simply go into your .vimrc (in vim) and add the following:
set t_kb=^?

Note that you don't want to type '^' and then '?', but rather hit <backspace>; this should create a ^? symbol (or, if you have some similar bug, whatever symbol it thinks is backspace).