1

I have added set term=xterm to my vimrc to be able to use 256-color vim schemes in terminal, but it comes at a price (at least for me). It also replaces (sort of) the BackSpace with Delete (i.e. BackSpace starts to delete forward just like Delete does) in insert mode and makes it "BackSpace" instead of moving left (or h) in normal mode. I have nothing against Ctrl-H as a way "to Backspace", but I simply don't want to have two delete buttons and ability "to BackSpace" (delete backward) in normal mode.

How can I reverse that change while retaining the setting I need?

PS I've read :h CTRL-h and a bit of :h xterm, but I couldn't find the solution.

Ahu Lee
  • 349
  • 5
  • 15
  • I am not really sure what your issue is, but `:h bs` may help – Doktor OSwaldo Dec 14 '18 at 07:21
  • @Doktor OSwaldo The issue is that adding `set term=xterm` line to `vimrc` changes `BackSpase` to `Delete` in insert mode and I don't like it. If by saying that `:h bs` may help you meant adding `set backspace=indent,eol,start` then no that's not my case. I had already had that in my `vimrc`. There's also `fixdel` for fixing BS or Del key (as it stated in the help), but I don't know what to do with it and if used on its own it has no effect. – Ahu Lee Dec 14 '18 at 08:47
  • `:h fixdel` documents what to do if your Backspace or Delete key doesn't work the way you want it it. That might fix your problem. – joanis Dec 14 '18 at 14:31
  • @joanis Thank you, but I've already mentioned it in my previous comment. – Ahu Lee Dec 14 '18 at 15:17
  • You're right, my apologies, I had not noticed it. I'm afraid I cannot be of any help, I didn't find anything else when I tried to figure out how to solve your problem earlier today. When I use set term=xterm I don't have the same problem. Maybe add the version of vim you're using, which xterm software, and other details about your configuration, in case that helps someone else figure it out for you. Maybe also provide the output of `stty --all`, in particular the value for `erase`, as that could be the source of your problem. – joanis Dec 14 '18 at 18:45
  • @joanis, no problem. I believe you don't have the same problem because you're on Linux and I'm using Windows. So, `stty --all` you mentioned is not my case. I'm using vim 8.1.576. I don't know what xterm software really is and I don't think I'm using (or have ever used) it. If you're interested in why I even bother with all of that then you can look here: https://conemu.github.io/en/VimXterm.html – Ahu Lee Dec 14 '18 at 19:13
  • 1
    It's true, we're working in a completely different environment. I assume the suggestions under "Fix Vim’s BS issue" in the page your linked also don't work for you, then. I just tried `set term=xterm` in my gvim on Windows and that just made the entire thing useless, with any keystroke just displaying many control characters instead of doing something reasonable. You're clearly working in a very specialized environment. Do they have their own help forum? – joanis Dec 14 '18 at 19:35
  • @joanis the page I linked is about "How to enable 256-color console Vim syntax highlight in ConEmu", so I have no idea how did you get to "Fix Vim’s BS issue" by following it. I don't know what you mean by "they" asking about the help forum. Okay, I think we should better stop here, because it already says "Please avoid extended discussions in comments and blah-blah". Thank you for your time! – Ahu Lee Dec 14 '18 at 19:58
  • @joanis You know what?! Thank you very much! You actually made me read the article till the end and find the solution. It was right there, but I didn't get to it because as I encountered the BS problem I immediately switched to it. That's funny. Could you please copy/paste the following as an answer so I could accept it (I can do it myself, but since you helped me I'd rather accept yours). The Answer: If you have problems with `BS` in Vim (`BS` acts like `Delete` key) under ConEmu when `term=xterm`, you may try to **remap** `BS` key: `inoremap ` `nnoremap ` – Ahu Lee Dec 14 '18 at 20:30

1 Answers1

1

Vim's inoremap and nnoremap commands can be used to adjust how keys are interpreted in Vim.

A solution is documented here for your specific context: https://conemu.github.io/en/VimXterm.html

The relevant quote: "If you have problems with BS in Vim (BS acts like Delete key) under ConEmu when term=xterm, you may try to remap BS key:

inoremap <Char-0x07F> <BS> 
nnoremap <Char-0x07F> <BS>

"

In general, when a key does not do what you want, the trick is to find out what it actually sends to Vim. Sometimes hitting Ctrl-V followed by that key in insert mode might help figure it out. Then inoremap and nnoremap as shown above can be used to reassign it to the behaviour you want in insert and normal modes, respectively.

joanis
  • 10,635
  • 14
  • 30
  • 40