Vim: Add a setting to toggle whether <Esc> closes autocomplete in insert mode.

Created on 4 Oct 2016  路  13Comments  路  Source: VSCodeVim/Vim

Please _thumbs-up_ 馃憤 this issue if it personally affects you! You can do this by clicking on the emoji-face on the top right of this post. Issues with more thumbs-up will be prioritized.


What did you do?

I type something that opens the autocomplete dropdown (typing the beginning of the name of a known symbol for example). After I stop typing, I press Escape to go back to normal mode.

What did you expect to happen?

The editor should change to normal mode.

What happened instead?

The escape key closed the autocomplete dropdown, without changing the vim mode. If I want to change to normal mode, I have to press escape twice.

Technical details:

  • VSCode Version: 1.5.3
  • VsCodeVim Version: 0.3.0
  • OS: Windows 8.1

I am not completetely sure if this also happened with 0.2.0, but I don't think so. Because right now many times when I'm trying to change to normal mode and save the file, it types in :w instead, which inserts a while loop in my code. This is really annoying because it completely destroys my workflow and it never saw that happening with 0.2.0.

Most helpful comment

I believe the API has changed a bit, so what @zyujs suggested didn't work for me. I modified the snippet slightly to get this:

  {
    "key": "escape",
    "command": "-extension.vim_escape",
    "when": "editorTextFocus && vim.active && !inDebugRepl"
  },
  {
    "key": "escape",
    "command": "extension.vim_escape",
    "when": "editorTextFocus && !inDebugRepl && !suggestWidgetVisible"
  }

The only slight difference is that you need to include a vim.active in the keybinding removal clause, since the default keybinding file for extension.vim_escape now contains vim.active.

All 13 comments

This is actually on purpose: https://github.com/VSCodeVim/Vim/issues/804

Is there a setting to turn this off?

Or rather: Could you add one?

Yes, that could be done. PRs welcome... 馃槈

I see what I can do once I have time.

Regarding that: Is there a way to use settings from settings.json in conditions in the when part of keybindings?

The current way to set this setting is by putting the following in keybindings.json:

 { "key": "escape",        "command": "extension.vim_escape",
                              "when": "editorTextFocus && !inDebugRepl" }

I've come around. You were right, this is incredibly annoying. If anyone wants the old behavior, they can add the setting. :P

Not working. I've checked the default keybindings.json. The solution above has been set default.

I also checked VSCode documentation. I didn't find inDebugRepl option. Instead, I saw inDebugMode. Tried. Still not working.

I also tried suggestWidgetVisible. Still.

you can try to add this to keybindings.json
{ "key": "escape", "command": "-extension.vim_escape", "when": "editorTextFocus && !inDebugRepl" }, { "command": "extension.vim_escape", "key": "escape", "when": "editorTextFocus && !inDebugRepl && !suggestWidgetVisible" },

@zyujs It works! Thank you! I didn't know that I could put this - in "command".

I believe the API has changed a bit, so what @zyujs suggested didn't work for me. I modified the snippet slightly to get this:

  {
    "key": "escape",
    "command": "-extension.vim_escape",
    "when": "editorTextFocus && vim.active && !inDebugRepl"
  },
  {
    "key": "escape",
    "command": "extension.vim_escape",
    "when": "editorTextFocus && !inDebugRepl && !suggestWidgetVisible"
  }

The only slight difference is that you need to include a vim.active in the keybinding removal clause, since the default keybinding file for extension.vim_escape now contains vim.active.

Thank you @mxchai! I had been looking for a way to still exit the search dialog box with escape while using vim.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

edwintorok picture edwintorok  路  3Comments

Jimmy-Z picture Jimmy-Z  路  3Comments

liamdawson picture liamdawson  路  3Comments

triztian picture triztian  路  3Comments

waltiam picture waltiam  路  3Comments