VSCodeVim / VSCodeVim/Vim

Discussion: `<Tab>` key

Open
#5,131 5 comments 5 reactions 1 assignee View on GitHub

@J-Fields is already working on this.

Since Aug 20, 2020.

kind/discussion
Dominant language
TypeScript
Stars
15.2k
Forks
1.5k
Avg merge
3d 18h
Merged PRs (30d)
6

Description

Describe the bug
Currently we can't capture the <Tab> key while in insert mode because that key needs to be handled by vscode so that the proper command is executed and there can be many commands depending on the situation like insertSnippet, jumpToNextSnippetPlaceholder, insertBestCompletion, insertNextSuggestion, editor.emmet.action.expandabbreviation among other commands that might be registered from other extensions.

This creates a long list of issues like the following (there is probably others I can't remember right now):

  1. Can't record macros as only keystrokes because we can't capture <Tab>
  2. Can't record . dot register as keystrokes because we can't capture <Tab>
  3. Can't record DotCommand as keystrokes because we can't capture <Tab>
  4. Can't store macros to disk because right know they are stored as complex RecordedState objects to include all the actions that look for and store document changes like the DocumentContentChangeAction
  5. Can't edit macros by simply copying a series of keys to some register like doing "ayiw on text ATest<Esc>j so that you can call that with @a and result in append 'Test' to the end of current line and move down.
  6. Right now with the change to selections when you enter a snippet with multicursors it enters MulticursorVisualMode and then you need to press c to change the selected text which puts you in MulticursorInsertMode, but if you then press <Tab> to go to the next placeholder, since we don't capture that key, we will change mode to MulticursorVisualMode again but we still have an unfinished DocumentContentChangeAction on the RecordedState that also includes an unfinished ChangeOperator action, so if you then press c to try to delete the selected text and enter MulticursorInsertMode it will actually do nothing, you'll have to press it a second time in order to work.
  7. Right now if we record a macro and replay a macro, or we try to insert last inserted text with <C-a> in a situation where we used <C-r> in insert mode to insert the text from some register it will always save the inserted text and it will always be the same even if we change the contents of that register. This is normal Vim behavior usually we would record the keystrokes and replay them which would result in pressing <C-r> again and then the register name, which would insert the updated register contents. This happens because we can't record only the keystrokes due to not being able to capture and resend the <Tab> key.

Additional context
I've opened this issue microsoft/vscode#104832 in vscode to see if it is possible to resend the <Tab> key to be handled normally again after we capture it and also send it again when needed, for example when replaying a macro.

@J-Fields If you can give your input on this and on the opened vscode issue I would really appreciate. Like I mentioned before, I don't really know the reasons behind using the RecordedState for macros instead of just keystrokes, but from looking into it I believe that this <Tab> key situation is the major issue. (maybe that situation with the remapper undoing a remapped inserted key might have created some issues but that should no longer be a problem now)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.