56

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

3
  • 2
    Don't know if this helps, but you can press CTRL+SPACE to bring up autocomplete. Commented Sep 8, 2019 at 12:29
  • @PeterWarrington I know how to bring up suggestions. My question is about using that suggestion with pressing of tab button Commented Sep 8, 2019 at 12:31
  • Oh I see, Sorry, Don't know how to help with that :-q. Commented Sep 8, 2019 at 12:32

16 Answers 16

69

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

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks this worked for me! I just clicked the "Tab Moves Focus" button you point to and it fixed it (i find clicking it to be easier to remember than the keyboard shortcut).
hitting ctrl+m for the android emulator dev tools (accidently in VS Code) was the issue for me
My saviour!!!!!
This was the solution I was looking for
You're a life saver !
|
51

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

1 Comment

Neither of these is working for me. editor.tabCompletion was off. When I turn it on it toggles between some options (e.g. div/device) but doesn't close tags or complete anything. Pressing Enter does nothing except enter a carriage return.
3

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.

Comments

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

Comments

2

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

enter image description here

2 Comments

This was the solution to my problem. Thank you!
You're welcome
1

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.

Comments

1

None of the other solutions worked for me until I tried this:

Step 1:

Ctrl + Shift + P

Step 2:

Select the following:

Open Keyboard Shortcuts (JSON)

Step 3:

Delete the following five lines:

{
  "key": "tab",
  "command": "editor.action.indentLines",
  "when": "editorTextFocus && !editorReadonly"
},

How did that line get there? I have no idea—probably a plugin.

Using tab to indent lines will still work as usual; all this change does is remove indenting lines from the "default control override" section, which somehow is blocking the default chain of command from working as intended upon pressing tab and preventing tab autocomplete from working.

Comments

0

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

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

1 Comment

Please don't repeat existing answers. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review
0

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

Comments

0
  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

1 Comment

The question is specifically about how to enable AutoCompletion using the Tab-button - I don't believe this answer solves that problem.
0

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.

Comments

0

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.

Comments

0
  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.

Comments

0

Do this:

"editor.suggest.selectionMode": "always"

Here is the image the VS Code config in settings:

The Image of VS code config in settings

Comments

0

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

Comments

0

If what you or anyone reading this desires is the tab key in VS Code to accept an inline suggestion when one is visible, and otherwise behave like a normal indent, this setup worked for me.

Add these two entries to keybindings.json:

{
    "key": "tab",
    "command": "tab"
},
{
    "key": "tab",
    "command": "editor.action.inlineSuggest.commit",
    "when": "inlineSuggestionVisible"
}

You might already have similar entries in your config; if so, adjust those instead of adding duplicates. But this is the configuration that worked for me.

If you want something similar alongside/instead of this type of inline suggestions, you might need something slightly different. This handles those ghost-text inline suggestions that appear inline as you type.

New contributor
Bradley Bush is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.