Correctly handle backspace in mappings
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
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:
- Add a
inoremap # X^H#mapping to the vimrc file (note that^His the literal backspace character. Can be inserted with ctrl+v followed by H) - Enable
vim.vimrc.enablein the vscode config - Enter
# - 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):
- Extension (VsCodeVim) version: 1.12.2
- VSCode version: 1.41.0 (9579eda04fdb3a9bba2750f15193e5fafe16b959)
- OS: Darwin x64 18.7.0
Additional context
This is a followup report to #4387
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named in the issue. Start by reproducing the inoremap # X^H# case with vim.vimrc.enable and compare the buffer output with the expected #; done means the literal backspace deletes the inserted X instead of appearing in the buffer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100