I'm using Visual Studio Code as my code editor. I did a search on google but wasn't able to find anything about my issue.

The issue is simple, pressing ⇥ Tab in the editor does nothing. I'm expecting it to insert 4 spaces.

Anyone know what I can do to get ⇥ Tab working like expected?

jps's user avatar

jps

22.6k16 gold badges88 silver badges106 bronze badges

asked Feb 20, 2016 at 5:28

5

I had accidentally enabled a different mode for the tab key. Fixed it by pressing Ctrl+Shift+M (for Mac), or Ctrl+M (for Windows and Linux).

From the Visual Studio Code Keybinding docs:

Command Key Command id
Toggle Use of Tab Key for Setting Focus Ctrl+M editor.action.toggleTabFocusMode

The current tab control mode should also show up in the status bar. It should say Tab Moves Focus:

user17726418's user avatar

user17726418

2,3628 gold badges16 silver badges34 bronze badges

answered Feb 25, 2017 at 15:56

pypmannetjies's user avatar

pypmannetjiespypmannetjies

31.6k7 gold badges42 silver badges49 bronze badges

8

Click "Tab Moves Focus" at the bottom right in the status bar. That's it.

enter image description here

I believe I had pressed ctrl+M. When doing this, the "Tab Moves Focus" tab/button showed up at the bottom right. Clicking on that makes it go away and starts working again.

You can type ctrl+M again to toggle it off as other answers have pointed out, but that's not as easy to remember as just clicking on it.

answered Oct 30, 2020 at 20:55

Tony L.'s user avatar

Tony L.Tony L.

19.5k8 gold badges72 silver badges68 bronze badges

6

To fix the issue

Pressing ctrl+M causes the ⇥ Tab key to move focus instead of inserting a ⇥ Tab character.
Turn it off by pressing the shortcut again.

To disable the shortcut

  1. Open "Keyboard Shortcuts" with ctrl+K, then ctrl+S.
    Or go to File > Preferences > Keyboard Shortcuts.
  2. Search for toggle tab key moves focus.
  3. Right Click, Remove Keybinding.

answered Aug 16, 2019 at 4:08

Addison's user avatar

AddisonAddison

8,4375 gold badges42 silver badges64 bronze badges

7

Click on the explorer or any other window that is not the editor then press Ctrl + Shift (for Mac only) + M, this is the command to "Toggle Tab Key Moves Focus" on the Keyboard Shortcuts.

JBallin's user avatar

JBallin

9,8174 gold badges49 silver badges62 bronze badges

answered Aug 21, 2019 at 17:42

Airton Gomes de Lima's user avatar

2

In, my case I followed this advice and changed this emmet setting in vscode to false:

"emmet.triggerExpansionOnTab": false

I was receinving the error Cannot read property 'value' of null. It solved the problem immediatelly.

Samuel RIGAUD's user avatar

answered Feb 19, 2018 at 19:01

Lucas Basquerotto's user avatar

1

As of December 2018 on macOS Mojave 10.14.2 using VSCode 1.29.1 the default keybinding for 'Toggle Tab Key Moves Focus' is set to Command+Shift+M. If you got stuck with this, using that key combo should fix the issue.

Do Command+K Command+S to pull up the Hotkeys Settings and then search for Toggle Tab Key Moves Focus or editor.action.toggleTabFocusMode if you want to change the key combo.

answered Dec 11, 2018 at 9:41

flux9998's user avatar

flux9998flux9998

3502 silver badges11 bronze badges

1

[Edit] This answer is for MSVS (the IDE, as opposed to VS Code). It seems Microsoft and Google go out of their way to choose confusing names for new products. I'll leave this answer here for now, while I (continue to) look for the equivalent stackoverflow question about MSVS. Let me know in the comments if you think I should delete it. Or better, point me to the MSVS version of this question.

I installed MSVS 2017 recently. None of the suggestions I've seen fixed the problem. The solution I figured out works for MSVS 2015 and 2017. Add a comment below if you find that it works for other versions.

Under Tools -> Options -> Text Editor -> C/C++ -> Formatting -> General, try unchecking the "Automatically indent when I type a tab" box. It seems counter intuitive, but it fixed the problem for me. enter image description here

answered Nov 4, 2019 at 22:31

riderBill's user avatar

riderBillriderBill

8989 silver badges17 bronze badges

2

All the above failed for me. But I noticed shift + ⇥ Tab worked as expected (outdenting the line).

So I looked for the "Indent Line" shortcut (which was assigned to alt + ctrl + cmd + 0 ), assigned it to tab, and now I'm happy again.


Next morning edit...

I also use tab to accept snippet suggestions, so I've set the "when" of "Indent Line" to editorTextFocus && !editorReadonly && !inSnippetMode && !suggestWidgetVisible.

Nazim Kerimbekov's user avatar

answered Mar 26, 2019 at 19:38

Félix Paradis's user avatar

Félix ParadisFélix Paradis

6,0816 gold badges44 silver badges53 bronze badges

1

I am using code on xfce - did the following to fix the Tab key behavior:

File -> Preferences -> Settings

search for "keyboard.dispatch"

copy to right panel and change value from "code" to "keyCode"

Reload code

answered Apr 22, 2018 at 9:28

Sagi's user avatar

SagiSagi

1091 silver badge1 bronze badge

For those of you not about that space bar life (- _ - )( - _ -)

  1. Keybinding for ⇥ Tab isn't set to anything so you have to do it manually

  2. Navigate to Preferences/Environment/Keybindings and search for "tab"

  3. Click on Edit Binding at the bottom and press the tab key.

  4. Press "Apply" then "Ok"

  5. Key bound!

Nazim Kerimbekov's user avatar

answered Jun 25, 2019 at 22:20

gooseberrytoptop's user avatar

For some reason, after an update, my tab key was unbinded of 'tab' default behaviour. So I have to open File>Preferences>Keyboad Shortcuts, search for the simple "tab" line, and bind to the tab key again. Pretty awkward, but worked.

answered May 7, 2021 at 14:40

Alexandre Macedo's user avatar

None of the other answers worked for me.

If your tab is not inserting space but focusing button element then following solution will work for you :)

Just set a keybindings to tab command like following image.

If your tab is not inserting space instead focusing then following solution will work for you

Eric Aya's user avatar

Eric Aya

70.1k36 gold badges189 silver badges259 bronze badges

answered Mar 3, 2023 at 6:23

Muhammad Sumon's user avatar

1

Maybe another program is interfering? Closing Teamviewer fixed the problem for me.

answered Jun 26, 2018 at 7:25

Steven Delrue's user avatar

1

I've had this happen before as well, where there was TeamViewer client takes the control of the TAB key. You won't know this until you close the TV window that you have open in the background.

Arash's user avatar

Arash

4,2607 gold badges49 silver badges82 bronze badges

answered Feb 3, 2020 at 7:03

vr_driver's user avatar

vr_drivervr_driver

2,08530 silver badges43 bronze badges

On Mac,
Preferences -> settings -> Search for "tab"
Uncheck Insert spaces when pressing tab enter image description here

answered Oct 23, 2021 at 15:56

Kishorekumar Yakkala's user avatar

Just restart the vscode it will do the job.

answered Aug 4, 2024 at 6:36

Nashid Mifzal's user avatar

1

Check your key mapping (File > Preferences > Key Mapping) [Ctrl+K Ctrl+S]. In the input line at the top write 'tab' and bind tab command with tab key.

It works for me. Some extension overwrite it.

answered Sep 15, 2021 at 6:40

Matt's user avatar

MattMatt

391 silver badge3 bronze badges

Make sure this is NOT checked :

[ ] Tools | Options | Text Editor | C/C++ | Formatting | Automatic Indentation On Tab

Let me know if this helped!

answered Apr 1, 2019 at 15:38

Archon 808's user avatar

Archon 808Archon 808

2001 silver badge8 bronze badges

1

In 2022, above not working any more, Microsoft changed the key binding

On Mac, Cmd + shift + M no longer working

Instead you should use : ctrl + shift + M

Here is evidence: enter image description here

answered Jan 20, 2022 at 18:22

hoogw's user avatar

hoogwhoogw

5,5631 gold badge45 silver badges36 bronze badges

1

Had the same issue on Mac. The Ctrl + Shift + M solution was not the correct one in my case. The indentation of a code line when pressing the Tab key was not possible because the key binding for indentation was set to a 4-key combination.

I did reset it to the Tab key in the key bindings settings (Preferences > Keyboard Shortcuts) and added && !config.emmet.triggerExpansionOnTab to the when expression, since I use the emmet plugin.

answered Feb 27, 2023 at 8:17

jessman5's user avatar

jessman5jessman5

3532 silver badges8 bronze badges

Not sure what operating system you're on, but there was a known issue with the tab key on one of the more recent releases of VS Code for Mac OS X. The bug has been fixed in the latest release (0.10.9).

On Mac OS X, you can check for the latest update by opening VS Code and then going to [Code > Check for Updates].

Sources and more information:

answered Feb 21, 2016 at 3:43

hxlnt's user avatar

hxlnthxlnt

6367 silver badges7 bronze badges

1

None of the above worked for me. For me, the issue was that the file wasn't editable by VSCode. You'll see a small padlock on the file tab on top. Just close the tab and open the file again. Tab should be working as usual.

answered Jun 2, 2022 at 12:59

Devorein's user avatar

DevoreinDevorein

1,3492 gold badges19 silver badges25 bronze badges

Problem could be caused by an Application on your computer

For me the problem got solved after closing Any Desk on my computer . I had it open to change some files on my remote server, and it's blocking the ability to tab
If you want to check , open your task manager and you will find it there. just right click it and select end task and tab will be back to normal.

AnyDesk

answered Jul 13, 2023 at 13:19

Yasser CHENIK's user avatar

Yasser CHENIKYasser CHENIK

4071 gold badge7 silver badges18 bronze badges

0