VSCodeVim / VSCodeVim/Vim

Correctly handle backspace in mappings

Open
#4,430 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/remap kind/bug
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:

  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):

  • 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.