Delete Key is changing letter case in Vim

Viewed 6574

I'm trying to get into Vim. I'm running it in the terminal on OS X.

Anytime I hit the delete key, it simply changes case of that letter instead of deleting it. When I SSH into my server and use Vim there, it deletes normally.

Any ideas what may be going wrong?

6 Answers

Well, this took forever for me to resolve. When using vim I was in Iterm2 on macOSx to access a Centos5 system via gnu screen. Not only was the delete key changing the letter case, and causing delays in vim, but also the arrow keys didnt work. I think the problem was simply in the old configuration on the Centos5 machine, but may have had something to also do with either iterm or gnu screen, but i hadnt had this issue at all on any Centos6 systems.

What did Not work: I compile vim 7.4, that did not resolve it, so don't go down that path. I also tried these configurations that did not work

"set term=ansi
"set backspace=indent,eol,start
"set nocompatible
"fixdel

":if &term == "xterm"
":if &term == "xterm-256"
":  set t_kD=^V<Delete>
":endif

"nmap <Ctrl-V><Del> x
"imap <Ctrl-V><Del> <Ctrl-V><Esc>xi

I finally found the solution.

Solution: Set the following in .vimrc

set term-builtin_xterm

Additionally, you may also notice that 256 colors have an issue on this same system. So if it helps, you can check your TERM environment variable echo $TERM. If it is xterm you can switch it to 256 colors, e.g. export TERM='xterm-256color to get the color schemes back on track for this same system. reference

I had the same issue where vim suddenly interpreted keys differently. The answer for me was that the environment variable $TERM had somehow been to to 'dumb' in my terminal.

I added

export TERM=xterm-color

to ~/.bashrc (in my case) and that fixed all the issues with keys; DEL worked as expected etc.

I didn't need to add or change anything in ~/.vimrc

I should mention this affected more than just vim for me - if you also see 'less' behave differently for example, you may have the same cause as I did.

None of these solutions worked for me, until I found a solution on the vim fandom website.

Those solutions are for a similar problems with arrow keys, which I was experiencing in addition to the delete key problem.

Solution 8 fixed it for me, the problem was that I had remapped <Esc> to <Esc>l in order to move the cursor right every time I entered normal mode, evidently this caused any other key code with included ^[ (which is the escape code) including the arrow keys ( ^[OA ^[OB etc ) and the delete key ( ^[[3~ ) to be misunderstood.

Removing the offending line from my .vimrc fixed the problem.

Related