ConEmu icon indicating copy to clipboard operation
ConEmu copied to clipboard

Vim backspace in xterm

Open farzadmf opened this issue 5 years ago • 11 comments

Versions

ConEmu build: 190331 [64] OS version: Windows Version 1709 (OS Build 16229.1087) Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): powershell-core and powershell

Problem description

I'm having problem with the backspace. It used to be fine before, but it's not currently (I don't know since when). When I press backspace in INSERT mode, it inserts characters Îx, AND when I press backspace in NORMAL mode, instead of moving back on characters, it deletes the character.

Steps to reproduce

  1. Open ConEmu
  2. Configure Vim to have these settings (put them in vimrc):
set encoding=utf-8

if !has('gui_running')
  set termencoding=utf-8
  set term=xterm
    
  inoremap <Char-0x07F> <BS>
  nnoremap <Char-0x07F> <BS>
    
  let &t_AB="\e[48;5;%dm"
  let &t_AF="\e[38;5;%dm"

  set t_Co=256
endif

Actual results

Go to INSERT mode, type something and press backspace, it inserts Îx, go to NORMAL mode, press backspace, and it will delete the characters

Expected results

The backspace in INSERT mode should remove the character, and in NORMAL mode, should just move back on the characters

It seems that the line set encoding=utf-8 has something to do with the display of those characters, but when I remove that line, pressing backspace will cause the mode to go to NORMAL mode, and then it deletes the characters (which is still unexpected because backspace in NORMAL mode shouldn't delete the characters)

farzadmf avatar Apr 24 '19 12:04 farzadmf

This is known issue, also arrow keys don't work if you use set term=xterm

ksawerykarwacki avatar Apr 25 '19 08:04 ksawerykarwacki

So, is there a plan to fix this? Because it used to work before :(

farzadmf avatar Apr 25 '19 14:04 farzadmf

I don't know if @Maximus5 plans to fix this, but I never had any working version and I always use preview versions.

ksawerykarwacki avatar Apr 25 '19 17:04 ksawerykarwacki

Actually, I never use arrow keys in Vim, so I'm not sure about them, but I'm pretty sure I didn't always have this issue with backspace

farzadmf avatar Apr 26 '19 18:04 farzadmf

This is not a known issue. This problem is appeared after I updated vim from 1025 to 1240.

Workaround which works for me:

let &t_kb="\xcex"

hulucc avatar May 01 '19 18:05 hulucc

I've added a bunch of remapping in _vimrc

" Conemu setup
if !empty($CONEMUHOOKS)
  " Conemu required for 256 bit color
  let &t_AB="\e[48;5;%dm"
  let &t_AF="\e[38;5;%dm"

  " Keyboard remappings for utf8 and conemu
  let &t_kb="\xcex" 
  let &t_ku="\xceH"
  let &t_kd="\xceP"
  let &t_kl="\xceK"
  let &t_kr="\xceM"
endif

Update: Fixed if to actually work.

warthurton avatar May 20 '19 17:05 warthurton

It is still broken for command-line mode.

EDIT: Specifically, Delete prints ÎS EDIT2: let &t_kD="\xceS" fixes it

kropptrevor avatar Jul 15 '19 17:07 kropptrevor

I've added a bunch of remapping in _vimrc " Conemu setup if !empty($CONEMUHOOKS) " Conemu required for 256 bit color let &t_AB="\e[48;5;%dm" let &t_AF="\e[38;5;%dm"

" Keyboard remappings for utf8 and conemu let &t_kb="\xcex" let &t_ku="\xceH" let &t_kd="\xceP" let &t_kl="\xceK" let &t_kr="\xceM" endif

Update: Fixed if to actually work.

This worked perfectly for me. After 3 days of struggling and searching for solution found it here … Perfect! Thnx!

bladane avatar Apr 05 '20 15:04 bladane

I've added a bunch of remapping in _vimrc

" Conemu setup
if !empty($CONEMUHOOKS)
  " Conemu required for 256 bit color
  let &t_AB="\e[48;5;%dm"
  let &t_AF="\e[38;5;%dm"

  " Keyboard remappings for utf8 and conemu
  let &t_kb="\xcex" 
  let &t_ku="\xceH"
  let &t_kd="\xceP"
  let &t_kl="\xceK"
  let &t_kr="\xceM"
endif

Update: Fixed if to actually work.

It is still broken for command-line mode.

EDIT: Specifically, Delete prints ÎS EDIT2: let &t_kD="\xceS" fixes it

Those worked for me! Thanksss!!!

luizzappa avatar Feb 09 '21 04:02 luizzappa

This worked for me! @Maximus5 could we add this fix the the documentation?

BananaHemic avatar Feb 18 '22 23:02 BananaHemic

I don't think this is related to ConEmu; none of the descriptions mention it, but for me, this issue happens regardless of whether pwsh is hosted in ConEmu. The same symptoms happen when running vim directly in cmd, powershell, or pwsh.

Does anyone understand what causes this issue in the first place? Because cursor keys and backspace have been working perfectly fine in my vim, including hosted in ConEmu, for months now, without having to have the remappings above in my vimrc. It only broke today, and the only thing I had changed in the meantime was updating pwsh from v7.3.5 to v7.4.0-preview4 b3044 (which only seems like a plausible trigger until I remember that it also broke things in cmd).

Edit: To be fair, I don't know if it worked properly in cmd or legacy PowerShell before the update. And to be even fairer, who knows what the pwsh installer might have fiddled around with somewhere else in the system. But I just installed the same pwsh version on my work laptop and didn't get the same issue, so it might not have been the trigger after all.

Anamon avatar Jul 03 '23 11:07 Anamon