Reza
Reza

Reputation: 3949

Tab autocomplete in Visual Studio Code doesn't work

I am trying to enable tab auto-completion with pressing "Tab" button but it doesn't work for me and it always works as Tab character when it is supposed to work as autocomplete. Which setting or shortcut should I enable or disable to have this feature?

Tab Auto-completion 1

With pressing "Tab", I will get this;

Tab Autocomplete 2

PS: Pressing "Enter" works fine and accepts the suggestion and I can disable it by setting the following setting to off.

enter image description here

Upvotes: 49

Views: 109112

Answers (14)

Drew Galbraith
Drew Galbraith

Reputation: 642

I found I had to press 'CTRL+m' to toggle whether the tab key would...

  • A) Move focus or
  • B) perform its assigned shortcut (e.g., autocomplete in the editor and terminal and accept suggestions).

Alternatively, try ctrl+shift+p (opens command pallete), then search and select 'Toggle Tab Moves Focus'.

*It doesn't solve OP's exact error, but I came looking here for this answer, and others may, too. :)VSC signaling what tab is doing atm

Upvotes: 47

Quwaysim
Quwaysim

Reputation: 407

What worked for me was to search "suggestion" under keyboard shortcuts and change acceptSelectedSuggestion from Enter to Tab.

enter image description here

Upvotes: 0

Maaz Ali
Maaz Ali

Reputation: 153

  1. Open Visual Studio Code Setting.
  2. Enable Tab Completion

Upvotes: 2

Hasnain Sikander
Hasnain Sikander

Reputation: 511

Well what worked for me is that I went to Keyboard Shortcuts and then in toggle the sort by precedence button on the left side of input and pressed the tab key. Like this enter image description here As you can see the Accept inline Suggestion is there but its precedence is far lower.

What I did then is

  1. open the default keyboard shortcut json file using Ctrl+Shift+P and typing open default shortcut
  2. search for tab key using ctrl+f
  3. find the one that says accepting inline suggestion
  4. copy the entire object or just copy this
{ "key": "tab", 
"command": "acceptSelectedSuggestion",
"when": "suggestWidgetHasFocusedSuggestion && suggestWidgetVisible && textInputFocus" },
  1. open the keybindings.json file using Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) and paste above JSON into it

Upvotes: 0

Kathan Jay Shah
Kathan Jay Shah

Reputation: 1

Do this:

"editor.suggest.selectionMode": "always"

Here is the image the VS Code config in settings:

The Image of VS code config in settings

Upvotes: 0

Aindriú
Aindriú

Reputation: 3740

Choose an option in the drop down and then try using Shift + Enter to confirm the suggestion.

If that works you can go to keyboard shortcuts in VSCode (File - Preferences - Keyboard Shortcuts) and search for Shift + Enter, you might see something like acceptAlternativeSelectedSuggestion and you could try changing that.

Upvotes: 1

egerinik
egerinik

Reputation: 1

  1. Ctrl+Shift+P
  2. Find "Emmet:Expand abbreviation"
  3. Set it to "Tab" key. Maybe first set it to any other key. Cheсk. If it's work - set back to TAB.

Upvotes: 0

Neelesh
Neelesh

Reputation: 1

You likely have a Keyboard Shortcut overriding the System default.

  1. File > Preferences > Keyboard Shortcuts
  2. Search "tab"
  3. Look for anything where the Source is "User" that is using a Keybinding "Tab"
  4. Right-click and Remove Binding.

Upvotes: 0

GCQ
GCQ

Reputation: 310

In my situation, I was working in a remote environment and my user settings weren't being applied to it (obviously).

environment tabs at top

This may be helpful to anyone who stumbles upon this question but the accepted answer doesn't work.

Just select your environment and then change the settings there.

Upvotes: 0

Deepak Singh
Deepak Singh

Reputation: 1145

  1. Open Visual Study Code Setting.

  2. Go to edit in settings.json.

  3. Add the below code:-

    "emmet.includeLanguages": {"javascript": "javascriptreact"},

enter image description here

enter image description here

Now have a fun 😄

enter image description here

Upvotes: 0

engtuncay
engtuncay

Reputation: 887

there may be keyboard shortcut conflicts in vs code. you should check keyboard shortcuts for tab, especially keyboard shortcuts come from extensions. if there is, you should remove it. then it will work.

Upvotes: 3

Vdoo
Vdoo

Reputation: 131

Control + P -> Terminal:Focus Terminal TabsView ->Click (). Or Ctrl + shift + \

Upvotes: 0

Shawn Adams
Shawn Adams

Reputation: 1

For HTML doing both the steps listed by Vinoth on Sep 08, 2019 worked for me:

  1. "editor.tabCompletion": "on"
  2. "emmet.triggerExpansionOnTab": true

Upvotes: 0

Vinoth A
Vinoth A

Reputation: 1239

Try changing tab completion setting to On:

Editor › tab Completion

"editor.tabCompletion": "on"

Also for HTML/Javascript you could make emmet setting to true

"emmet.triggerExpansionOnTab": true

Upvotes: 49

Related Questions