VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.9k stars 1.32k forks source link

Correctly handle backspace in mappings #4430

Open mitsuhiko opened 4 years ago

mitsuhiko commented 4 years ago

Describe the bug This is a followup to #4387. If one defines a mapping containing the literal backspace character (shown as ^H in vim) the behavior of vim and vscode differs. In vim the delete is performed, in vscode it inserts the literal delete character.

This sounds unimportant but backspaces are not uncommon in vim due to the old special behavior of how indents and backspace interacts. For instance this is a very common configuration in vim to fix up smartindent:

inoremap # X^H#

As vscode can load vimrc files I believe it's important to correctly replicate this behavior.

To Reproduce Steps to reproduce the behavior:

  1. Add a inoremap # X^H# mapping to the vimrc file (note that ^H is the literal backspace character. Can be inserted with ctrl+v followed by H)
  2. Enable vim.vimrc.enable in the vscode config
  3. Enter #
  4. Observe X^H# being written to the buffer as opposed to #.

Expected behavior Only # should be written as the inserted X should be deleted by the inserted ^H.

Screenshots

Environment (please complete the following information):

Additional context

This is a followup report to #4387

J-Fields commented 4 years ago

As a workaround, we do handle <BS> correctly in remappings