How to customize the tab-to-space conversion factor when using Visual Studio Code? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to set per-filetype tab size?How to change the per-language configuration of setting “editor.insertSpaces” to “auto”Copying code from Visual Studio Code to OneNote loses tab indentations even though syntax highlighting is retainedPreserve spacing on indent or outdent with tab in VSCodeVisual Studio Code tab widthHow to select tab-size in Visual Code Studio for pug lang?How can I configure wrapping indent size in VS Code?Too much space in loopManaging Indentation Settings in VS CodeVS Code - How do I change Format Document to use tabs instead of spacesMultiple cursors in Visual Studio CodeVertical rulers in Visual Studio Code?How do you format code in Visual Studio Code (VSCode)visual studio code compile on saveHow to use Visual Studio Code as Default Editor for GitHow do I collapse sections of code in Visual Studio Code for Windows?How do I hide certain files from the sidebar in Visual Studio Code?Hide .js.map files in Visual Studio CodeSpaces to tabs in Visual Studio CodeHow do I configure Visual Studio Code to open files always in a new tab?

Why are two-digit numbers in Jonathan Swift's "Gulliver's Travels" (1726) written in "German style"?

How to get a flat-head nail out of a piece of wood?

Magento 2 Editing phtml files in Production Mode

RM anova or Factorial Anova?

Combining list in a Cartesian product format with addition operation?

Can two people see the same photon?

Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?

Can I feed enough spin up electron to a black hole to affect it's angular momentum?

IC on Digikey is 5x more expensive than board containing same IC on Alibaba: How?

Noise in Eigenvalues plot

Why do C and C++ allow the expression (int) + 4*5?

How to create a button that adds InputFields when clicked?

"Destructive power" carried by a B-52?

Flight departed from the gate 5 min before scheduled departure time. Refund options

Can anyone explain what's the meaning of this in the new Game of Thrones opening animations?

How to ask rejected full-time candidates to apply to teach individual courses?

draw a pulley system

How can I list files in reverse time order by a command and pass them as arguments to another command?

No invitation for tourist visa but I want to visit

How does Billy Russo acquire his 'Jigsaw' mask?

Lemmatization Vs Stemming

malloc in main() or malloc in another function: allocating memory for a struct and its members

Why did Israel vote against lifting the American embargo on Cuba?

Is there a verb for listening stealthily?



How to customize the tab-to-space conversion factor when using Visual Studio Code?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to set per-filetype tab size?How to change the per-language configuration of setting “editor.insertSpaces” to “auto”Copying code from Visual Studio Code to OneNote loses tab indentations even though syntax highlighting is retainedPreserve spacing on indent or outdent with tab in VSCodeVisual Studio Code tab widthHow to select tab-size in Visual Code Studio for pug lang?How can I configure wrapping indent size in VS Code?Too much space in loopManaging Indentation Settings in VS CodeVS Code - How do I change Format Document to use tabs instead of spacesMultiple cursors in Visual Studio CodeVertical rulers in Visual Studio Code?How do you format code in Visual Studio Code (VSCode)visual studio code compile on saveHow to use Visual Studio Code as Default Editor for GitHow do I collapse sections of code in Visual Studio Code for Windows?How do I hide certain files from the sidebar in Visual Studio Code?Hide .js.map files in Visual Studio CodeSpaces to tabs in Visual Studio CodeHow do I configure Visual Studio Code to open files always in a new tab?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








607















How to customize the tab-to-space conversion factor when using Visual Studio Code?



For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4.










share|improve this question






























    607















    How to customize the tab-to-space conversion factor when using Visual Studio Code?



    For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4.










    share|improve this question


























      607












      607








      607


      95






      How to customize the tab-to-space conversion factor when using Visual Studio Code?



      For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4.










      share|improve this question
















      How to customize the tab-to-space conversion factor when using Visual Studio Code?



      For instance, right now in HTML it appears to produce two spaces per press of TAB, but in TypeScript it produces 4.







      visual-studio-code vscode-settings






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 4 at 16:19









      Braiam

      3,59993566




      3,59993566










      asked Apr 30 '15 at 15:54









      J. AbrahamsonJ. Abrahamson

      49.5k7114160




      49.5k7114160






















          17 Answers
          17






          active

          oldest

          votes


















          975














          By default, Visual Studio Code will try to guess your indentation options depending on the file you open.



          You can turn off indentation guessing via "editor.detectIndentation": false.



          You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:



          // The number of spaces a tab is equal to. This setting is overridden
          // based on the file contents when `editor.detectIndentation` is true.
          "editor.tabSize": 4,

          // Insert spaces when pressing Tab. This setting is overriden
          // based on the file contents when `editor.detectIndentation` is true.
          "editor.insertSpaces": true,

          // When opening a file, `editor.tabSize` and `editor.insertSpaces`
          // will be detected based on the file contents. Set to false to keep
          // the values you've explicitly set, above.
          "editor.detectIndentation": false





          share|improve this answer




















          • 4





            I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

            – Guss
            May 7 '15 at 9:49







          • 3





            Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

            – Stijn de Witt
            Oct 7 '16 at 12:43






          • 3





            This did not work when i tried it with a .json file.

            – arcseldon
            Oct 12 '16 at 12:32






          • 5





            Adding ` "editor.detectIndentation": false` worked in my case.

            – arcseldon
            Oct 12 '16 at 12:36






          • 2





            If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

            – Jamie Nordmeyer
            Aug 14 '18 at 19:28


















          538





          +50









          I'm running version 1.21 but I think this may apply to earlier versions as well.



          Take a look at the bottom right-hand side of the screen. You should see something that says Spaces or Tab-Size.



          Mine shows spaces, -->
          enter image description here



          1. Click on the Spaces (or Tab-Size)

          2. Choose Indent Using Spaces or Indent using Tabs

          3. Select the amount of spaces or tabs you like.

          This only works per document, not project-wide. If you want to apply it project-wide, you need to also add "editor.detectIndentation": false to your user settings.






          share|improve this answer




















          • 3





            nice. just need to right click on the file then choose format code to do the conversion.

            – Meirion Hughes
            Aug 18 '16 at 11:09






          • 7





            Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

            – DarthOpto
            Nov 8 '16 at 16:41











          • I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

            – Darren Evans
            Apr 12 '17 at 12:40






          • 1





            VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

            – chriszo111
            Nov 15 '18 at 14:13


















          126














          Well, the new version of Visual Studio Code allows you to specify differently file type for the tabSize. Here is the example of my settings.json with default 4 spaces and JavaScript/JSON 2 spaces:




          // I want my default to be 4, but JS/JSON to be 2
          "editor.tabSize": 4,
          "[javascript]":
          "editor.tabSize": 2
          ,
          "[json]":
          "editor.tabSize": 2




          PS: Well, if you do not know how to open this file, you can: click left-bottom gear -> then settings






          share|improve this answer




















          • 9





            Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

            – Jose A
            Oct 6 '17 at 13:17


















          102














          By default, Visual Studio Code auto-detects the indentation of the current open file. If you want to switch this feature off and make all indentation, for example, two spaces, you'd do the following in your User Settings or Workspace settings.




          "editor.tabSize": 2,

          "editor.detectIndentation": false






          share|improve this answer




















          • 2





            And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

            – LoBo
            May 26 '17 at 14:48











          • ...why would you do that? Can't you just use the convert indentation command?

            – celticminstrel
            Aug 6 '18 at 16:04


















          48














          We can control tab size by file type with EditorConfig and its Visual Studio Code extension. We then can make Alt + Shift + F specific to each file type.



          Installation



          ext install EditorConfig


          Example Configuration



          .editorconfig



          [*]
          indent_style = space

          [*.cs,js]
          indent_size = 4

          [*.json]
          indent_size = 2


          settings.json



          EditorConfig overrides whatever settings.json configures for the editor. There is no need to change editor.detectIndentation.






          share|improve this answer
































            6














            You want to make sure your editorconfig is not conflicting with your user or workspace settings configuration, as I just had a bit of annoyance thinking the settings files settings were not being applied when it was my editor configuration undoing those changes.






            share|improve this answer
































              6














              That is lonefy.vscode-js-css-html-formatter to blame. Disable it, and install HookyQR.beautify.



              Now on save your tabs wouldn't be converted.






              share|improve this answer
































                3














                In VSC version 1.31.1 or more (I think).
                Like sed Alex Dima.
                You can customize this easily via these settings for



                • Windows in menu File → Preferences → User Settings or use short keys ctr + shift + p

                • Mac in menu Code → Preferences → Settings or ⌘,

                enter image description here



                enter image description here






                share|improve this answer






























                  3














                  If you use the prettier extension in vscode, try adding this to the settings.json file:



                  "editor.insertSpaces": false,
                  "editor.tabSize": 4,
                  "editor.detectIndentation": false,

                  "prettier.tabWidth": 4,
                  "prettier.useTabs": true // this made it finally work for me





                  share|improve this answer






























                    3














                    In your bottom-right corner, you have Spaces:
                    Spaces: 2



                    There you can change the indentation according to your needs:
                    Indentation Options






                    share|improve this answer






























                      2














                      If the accepted answer on this post doesn't work, give this a try:



                      I had EditorConfig for Visual Studio Code installed in my editor, and it kept overriding my user settings which were set to indent files using spaces. Every time I switched between editor tabs, my file would automatically get indented with tabs even if I had converted indentation to spaces!!!



                      Right after I uninstalled this extension, indentation no longer changes between switching editor tabs, and I can work more comfortably rather than having to manually convert tabs to spaces every time I switch files - that is painful.






                      share|improve this answer

























                      • this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                        – Esteban
                        Feb 20 at 20:12


















                      1














                      @alex-dima's solution from 2015 will change tab sizes and spaces for all files and @Tricky's solution from 2016 appears to only change the settings for the current file.



                      As of 2017, I found another solution that works on a per-language basis. Visual Studio Code was not using the proper tab sizes or space settings for Elixir, so I found that I could change the settings for all Elixir files.



                      I clicked on the language in the status bar ("Elixir" in my case), chose "Configure 'Elixir' language based settings...", and edited the Elixir-specific language settings. I just copied the "editor.tabSize" and "editor.insertSpaces" settings from the default settings on the left (I'm so glad those are shown) and then modified them on the right.



                      It worked great, and now all Elixir language files use the proper tab size and space settings.






                      share|improve this answer






























                        1














                        Menu FilePreferencesSettings



                        Add to user settings:



                        "editor.tabSize": 2,
                        "editor.detectIndentation": false


                        then right click your document if you have one opened already and click Format Document to have your existing document follow these new settings.






                        share|improve this answer
































                          1














                          When using TypeScript, the default tab width is always two regardless of what it says in the toolbar. You have to set "prettier.tabWidth" in your user settings to change it.



                          Ctrl + P, Type → user settings, add:



                          "prettier.tabWidth": 4





                          share|improve this answer
































                            0














                            User3550138 is correct. lonefy.vscode-js-css-html-formatter overrides all the settings mentioned in other answers. However, you don't have to disable or uninstall it as it can be configured.



                            Full instructions can be found by opening the extensions sidebar and clicking on this extension and it will display configuration instructions in the editor workspace. At least it does for me in Visual Studio Code version 1.14.1.






                            share|improve this answer
































                              0














                              If this is for Angular 2, and the CLI is generating files which you would like differently formatted, you can edit these files to change what is generated:



                              npm_modules/@angular/cli/blueprints/component/files/__path__/*


                              Not massively recommended as an npm update will delete your work, but it has saved me a lot of time.






                              share|improve this answer
































                                0














                                I tried to change editor.tabSize to 4, but .editorConfig overrides whatever settings I had specified, so there is no need to change any configuration in user settings. You just need to edit .editorConfig file:



                                set indent_size = 4





                                share|improve this answer

























                                  Your Answer






                                  StackExchange.ifUsing("editor", function ()
                                  StackExchange.using("externalEditor", function ()
                                  StackExchange.using("snippets", function ()
                                  StackExchange.snippets.init();
                                  );
                                  );
                                  , "code-snippets");

                                  StackExchange.ready(function()
                                  var channelOptions =
                                  tags: "".split(" "),
                                  id: "1"
                                  ;
                                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                  StackExchange.using("externalEditor", function()
                                  // Have to fire editor after snippets, if snippets enabled
                                  if (StackExchange.settings.snippets.snippetsEnabled)
                                  StackExchange.using("snippets", function()
                                  createEditor();
                                  );

                                  else
                                  createEditor();

                                  );

                                  function createEditor()
                                  StackExchange.prepareEditor(
                                  heartbeatType: 'answer',
                                  autoActivateHeartbeat: false,
                                  convertImagesToLinks: true,
                                  noModals: true,
                                  showLowRepImageUploadWarning: true,
                                  reputationToPostImages: 10,
                                  bindNavPrevention: true,
                                  postfix: "",
                                  imageUploader:
                                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                  allowUrls: true
                                  ,
                                  onDemand: true,
                                  discardSelector: ".discard-answer"
                                  ,immediatelyShowMarkdownHelp:true
                                  );



                                  );













                                  draft saved

                                  draft discarded


















                                  StackExchange.ready(
                                  function ()
                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29972396%2fhow-to-customize-the-tab-to-space-conversion-factor-when-using-visual-studio-cod%23new-answer', 'question_page');

                                  );

                                  Post as a guest















                                  Required, but never shown

























                                  17 Answers
                                  17






                                  active

                                  oldest

                                  votes








                                  17 Answers
                                  17






                                  active

                                  oldest

                                  votes









                                  active

                                  oldest

                                  votes






                                  active

                                  oldest

                                  votes









                                  975














                                  By default, Visual Studio Code will try to guess your indentation options depending on the file you open.



                                  You can turn off indentation guessing via "editor.detectIndentation": false.



                                  You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:



                                  // The number of spaces a tab is equal to. This setting is overridden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.tabSize": 4,

                                  // Insert spaces when pressing Tab. This setting is overriden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.insertSpaces": true,

                                  // When opening a file, `editor.tabSize` and `editor.insertSpaces`
                                  // will be detected based on the file contents. Set to false to keep
                                  // the values you've explicitly set, above.
                                  "editor.detectIndentation": false





                                  share|improve this answer




















                                  • 4





                                    I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                    – Guss
                                    May 7 '15 at 9:49







                                  • 3





                                    Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                    – Stijn de Witt
                                    Oct 7 '16 at 12:43






                                  • 3





                                    This did not work when i tried it with a .json file.

                                    – arcseldon
                                    Oct 12 '16 at 12:32






                                  • 5





                                    Adding ` "editor.detectIndentation": false` worked in my case.

                                    – arcseldon
                                    Oct 12 '16 at 12:36






                                  • 2





                                    If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                    – Jamie Nordmeyer
                                    Aug 14 '18 at 19:28















                                  975














                                  By default, Visual Studio Code will try to guess your indentation options depending on the file you open.



                                  You can turn off indentation guessing via "editor.detectIndentation": false.



                                  You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:



                                  // The number of spaces a tab is equal to. This setting is overridden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.tabSize": 4,

                                  // Insert spaces when pressing Tab. This setting is overriden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.insertSpaces": true,

                                  // When opening a file, `editor.tabSize` and `editor.insertSpaces`
                                  // will be detected based on the file contents. Set to false to keep
                                  // the values you've explicitly set, above.
                                  "editor.detectIndentation": false





                                  share|improve this answer




















                                  • 4





                                    I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                    – Guss
                                    May 7 '15 at 9:49







                                  • 3





                                    Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                    – Stijn de Witt
                                    Oct 7 '16 at 12:43






                                  • 3





                                    This did not work when i tried it with a .json file.

                                    – arcseldon
                                    Oct 12 '16 at 12:32






                                  • 5





                                    Adding ` "editor.detectIndentation": false` worked in my case.

                                    – arcseldon
                                    Oct 12 '16 at 12:36






                                  • 2





                                    If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                    – Jamie Nordmeyer
                                    Aug 14 '18 at 19:28













                                  975












                                  975








                                  975







                                  By default, Visual Studio Code will try to guess your indentation options depending on the file you open.



                                  You can turn off indentation guessing via "editor.detectIndentation": false.



                                  You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:



                                  // The number of spaces a tab is equal to. This setting is overridden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.tabSize": 4,

                                  // Insert spaces when pressing Tab. This setting is overriden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.insertSpaces": true,

                                  // When opening a file, `editor.tabSize` and `editor.insertSpaces`
                                  // will be detected based on the file contents. Set to false to keep
                                  // the values you've explicitly set, above.
                                  "editor.detectIndentation": false





                                  share|improve this answer















                                  By default, Visual Studio Code will try to guess your indentation options depending on the file you open.



                                  You can turn off indentation guessing via "editor.detectIndentation": false.



                                  You can customize this easily via these three settings for Windows in menu FilePreferencesUser Settings and for Mac in menu CodePreferencesSettings or ⌘,:



                                  // The number of spaces a tab is equal to. This setting is overridden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.tabSize": 4,

                                  // Insert spaces when pressing Tab. This setting is overriden
                                  // based on the file contents when `editor.detectIndentation` is true.
                                  "editor.insertSpaces": true,

                                  // When opening a file, `editor.tabSize` and `editor.insertSpaces`
                                  // will be detected based on the file contents. Set to false to keep
                                  // the values you've explicitly set, above.
                                  "editor.detectIndentation": false






                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 15 '18 at 17:59









                                  Peter Mortensen

                                  14k1987114




                                  14k1987114










                                  answered Apr 30 '15 at 16:02









                                  Alex DimaAlex Dima

                                  11k1812




                                  11k1812







                                  • 4





                                    I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                    – Guss
                                    May 7 '15 at 9:49







                                  • 3





                                    Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                    – Stijn de Witt
                                    Oct 7 '16 at 12:43






                                  • 3





                                    This did not work when i tried it with a .json file.

                                    – arcseldon
                                    Oct 12 '16 at 12:32






                                  • 5





                                    Adding ` "editor.detectIndentation": false` worked in my case.

                                    – arcseldon
                                    Oct 12 '16 at 12:36






                                  • 2





                                    If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                    – Jamie Nordmeyer
                                    Aug 14 '18 at 19:28












                                  • 4





                                    I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                    – Guss
                                    May 7 '15 at 9:49







                                  • 3





                                    Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                    – Stijn de Witt
                                    Oct 7 '16 at 12:43






                                  • 3





                                    This did not work when i tried it with a .json file.

                                    – arcseldon
                                    Oct 12 '16 at 12:32






                                  • 5





                                    Adding ` "editor.detectIndentation": false` worked in my case.

                                    – arcseldon
                                    Oct 12 '16 at 12:36






                                  • 2





                                    If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                    – Jamie Nordmeyer
                                    Aug 14 '18 at 19:28







                                  4




                                  4





                                  I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                  – Guss
                                  May 7 '15 at 9:49






                                  I have configured both settings to "auto", and the behavior is not as I expect (though I wouldn't go as far as to call it "wrong"). I don't know what file should be changed to support my convention, but I opened a uservoice ticket for that, as suggested in the answer to question #30057721

                                  – Guss
                                  May 7 '15 at 9:49





                                  3




                                  3





                                  Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                  – Stijn de Witt
                                  Oct 7 '16 at 12:43





                                  Is there also an option to set the default for new, blank files? There's not much to guess in that scenario and I think VSCode will default to using spaces (which I don't prefer)...

                                  – Stijn de Witt
                                  Oct 7 '16 at 12:43




                                  3




                                  3





                                  This did not work when i tried it with a .json file.

                                  – arcseldon
                                  Oct 12 '16 at 12:32





                                  This did not work when i tried it with a .json file.

                                  – arcseldon
                                  Oct 12 '16 at 12:32




                                  5




                                  5





                                  Adding ` "editor.detectIndentation": false` worked in my case.

                                  – arcseldon
                                  Oct 12 '16 at 12:36





                                  Adding ` "editor.detectIndentation": false` worked in my case.

                                  – arcseldon
                                  Oct 12 '16 at 12:36




                                  2




                                  2





                                  If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                  – Jamie Nordmeyer
                                  Aug 14 '18 at 19:28





                                  If you have the "prettier" extension installed, make sure to also set the prettier.tabWidth value to 4. I just ran in to this today. :)

                                  – Jamie Nordmeyer
                                  Aug 14 '18 at 19:28













                                  538





                                  +50









                                  I'm running version 1.21 but I think this may apply to earlier versions as well.



                                  Take a look at the bottom right-hand side of the screen. You should see something that says Spaces or Tab-Size.



                                  Mine shows spaces, -->
                                  enter image description here



                                  1. Click on the Spaces (or Tab-Size)

                                  2. Choose Indent Using Spaces or Indent using Tabs

                                  3. Select the amount of spaces or tabs you like.

                                  This only works per document, not project-wide. If you want to apply it project-wide, you need to also add "editor.detectIndentation": false to your user settings.






                                  share|improve this answer




















                                  • 3





                                    nice. just need to right click on the file then choose format code to do the conversion.

                                    – Meirion Hughes
                                    Aug 18 '16 at 11:09






                                  • 7





                                    Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                    – DarthOpto
                                    Nov 8 '16 at 16:41











                                  • I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                    – Darren Evans
                                    Apr 12 '17 at 12:40






                                  • 1





                                    VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                    – chriszo111
                                    Nov 15 '18 at 14:13















                                  538





                                  +50









                                  I'm running version 1.21 but I think this may apply to earlier versions as well.



                                  Take a look at the bottom right-hand side of the screen. You should see something that says Spaces or Tab-Size.



                                  Mine shows spaces, -->
                                  enter image description here



                                  1. Click on the Spaces (or Tab-Size)

                                  2. Choose Indent Using Spaces or Indent using Tabs

                                  3. Select the amount of spaces or tabs you like.

                                  This only works per document, not project-wide. If you want to apply it project-wide, you need to also add "editor.detectIndentation": false to your user settings.






                                  share|improve this answer




















                                  • 3





                                    nice. just need to right click on the file then choose format code to do the conversion.

                                    – Meirion Hughes
                                    Aug 18 '16 at 11:09






                                  • 7





                                    Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                    – DarthOpto
                                    Nov 8 '16 at 16:41











                                  • I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                    – Darren Evans
                                    Apr 12 '17 at 12:40






                                  • 1





                                    VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                    – chriszo111
                                    Nov 15 '18 at 14:13













                                  538





                                  +50







                                  538





                                  +50



                                  538




                                  +50





                                  I'm running version 1.21 but I think this may apply to earlier versions as well.



                                  Take a look at the bottom right-hand side of the screen. You should see something that says Spaces or Tab-Size.



                                  Mine shows spaces, -->
                                  enter image description here



                                  1. Click on the Spaces (or Tab-Size)

                                  2. Choose Indent Using Spaces or Indent using Tabs

                                  3. Select the amount of spaces or tabs you like.

                                  This only works per document, not project-wide. If you want to apply it project-wide, you need to also add "editor.detectIndentation": false to your user settings.






                                  share|improve this answer















                                  I'm running version 1.21 but I think this may apply to earlier versions as well.



                                  Take a look at the bottom right-hand side of the screen. You should see something that says Spaces or Tab-Size.



                                  Mine shows spaces, -->
                                  enter image description here



                                  1. Click on the Spaces (or Tab-Size)

                                  2. Choose Indent Using Spaces or Indent using Tabs

                                  3. Select the amount of spaces or tabs you like.

                                  This only works per document, not project-wide. If you want to apply it project-wide, you need to also add "editor.detectIndentation": false to your user settings.







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Apr 4 '18 at 10:22









                                  shiri

                                  620622




                                  620622










                                  answered Jun 28 '16 at 18:18









                                  TrickyTricky

                                  5,7111109




                                  5,7111109







                                  • 3





                                    nice. just need to right click on the file then choose format code to do the conversion.

                                    – Meirion Hughes
                                    Aug 18 '16 at 11:09






                                  • 7





                                    Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                    – DarthOpto
                                    Nov 8 '16 at 16:41











                                  • I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                    – Darren Evans
                                    Apr 12 '17 at 12:40






                                  • 1





                                    VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                    – chriszo111
                                    Nov 15 '18 at 14:13












                                  • 3





                                    nice. just need to right click on the file then choose format code to do the conversion.

                                    – Meirion Hughes
                                    Aug 18 '16 at 11:09






                                  • 7





                                    Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                    – DarthOpto
                                    Nov 8 '16 at 16:41











                                  • I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                    – Darren Evans
                                    Apr 12 '17 at 12:40






                                  • 1





                                    VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                    – chriszo111
                                    Nov 15 '18 at 14:13







                                  3




                                  3





                                  nice. just need to right click on the file then choose format code to do the conversion.

                                  – Meirion Hughes
                                  Aug 18 '16 at 11:09





                                  nice. just need to right click on the file then choose format code to do the conversion.

                                  – Meirion Hughes
                                  Aug 18 '16 at 11:09




                                  7




                                  7





                                  Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                  – DarthOpto
                                  Nov 8 '16 at 16:41





                                  Much clearer solution than the accepted answer. I could not even edit the file in the accepted answer. This actually worked.

                                  – DarthOpto
                                  Nov 8 '16 at 16:41













                                  I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                  – Darren Evans
                                  Apr 12 '17 at 12:40





                                  I'm using VS Code on Windows. Using the tab indicator on the status bar method to change tab settings works for most files but is not working in .cshtml files? Can anyone confirm?

                                  – Darren Evans
                                  Apr 12 '17 at 12:40




                                  1




                                  1





                                  VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                  – chriszo111
                                  Nov 15 '18 at 14:13





                                  VSCode warns now if editor.detectIndentation is set to true and you change the editor.tabSize. However, since the GUI for settings.json or user-settings.json it's easier to change this now.

                                  – chriszo111
                                  Nov 15 '18 at 14:13











                                  126














                                  Well, the new version of Visual Studio Code allows you to specify differently file type for the tabSize. Here is the example of my settings.json with default 4 spaces and JavaScript/JSON 2 spaces:




                                  // I want my default to be 4, but JS/JSON to be 2
                                  "editor.tabSize": 4,
                                  "[javascript]":
                                  "editor.tabSize": 2
                                  ,
                                  "[json]":
                                  "editor.tabSize": 2




                                  PS: Well, if you do not know how to open this file, you can: click left-bottom gear -> then settings






                                  share|improve this answer




















                                  • 9





                                    Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                    – Jose A
                                    Oct 6 '17 at 13:17















                                  126














                                  Well, the new version of Visual Studio Code allows you to specify differently file type for the tabSize. Here is the example of my settings.json with default 4 spaces and JavaScript/JSON 2 spaces:




                                  // I want my default to be 4, but JS/JSON to be 2
                                  "editor.tabSize": 4,
                                  "[javascript]":
                                  "editor.tabSize": 2
                                  ,
                                  "[json]":
                                  "editor.tabSize": 2




                                  PS: Well, if you do not know how to open this file, you can: click left-bottom gear -> then settings






                                  share|improve this answer




















                                  • 9





                                    Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                    – Jose A
                                    Oct 6 '17 at 13:17













                                  126












                                  126








                                  126







                                  Well, the new version of Visual Studio Code allows you to specify differently file type for the tabSize. Here is the example of my settings.json with default 4 spaces and JavaScript/JSON 2 spaces:




                                  // I want my default to be 4, but JS/JSON to be 2
                                  "editor.tabSize": 4,
                                  "[javascript]":
                                  "editor.tabSize": 2
                                  ,
                                  "[json]":
                                  "editor.tabSize": 2




                                  PS: Well, if you do not know how to open this file, you can: click left-bottom gear -> then settings






                                  share|improve this answer















                                  Well, the new version of Visual Studio Code allows you to specify differently file type for the tabSize. Here is the example of my settings.json with default 4 spaces and JavaScript/JSON 2 spaces:




                                  // I want my default to be 4, but JS/JSON to be 2
                                  "editor.tabSize": 4,
                                  "[javascript]":
                                  "editor.tabSize": 2
                                  ,
                                  "[json]":
                                  "editor.tabSize": 2




                                  PS: Well, if you do not know how to open this file, you can: click left-bottom gear -> then settings







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 18 '18 at 0:15

























                                  answered May 10 '17 at 3:28









                                  XinXin

                                  7,87944047




                                  7,87944047







                                  • 9





                                    Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                    – Jose A
                                    Oct 6 '17 at 13:17












                                  • 9





                                    Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                    – Jose A
                                    Oct 6 '17 at 13:17







                                  9




                                  9





                                  Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                  – Jose A
                                  Oct 6 '17 at 13:17





                                  Beautiful. It works! Some quick addition to that, the thing between the brackets, if you look at the lower right corner of visual studio, you can spot the name to use! Check it out: tinypic.com/m/jr9nw1/3

                                  – Jose A
                                  Oct 6 '17 at 13:17











                                  102














                                  By default, Visual Studio Code auto-detects the indentation of the current open file. If you want to switch this feature off and make all indentation, for example, two spaces, you'd do the following in your User Settings or Workspace settings.




                                  "editor.tabSize": 2,

                                  "editor.detectIndentation": false






                                  share|improve this answer




















                                  • 2





                                    And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                    – LoBo
                                    May 26 '17 at 14:48











                                  • ...why would you do that? Can't you just use the convert indentation command?

                                    – celticminstrel
                                    Aug 6 '18 at 16:04















                                  102














                                  By default, Visual Studio Code auto-detects the indentation of the current open file. If you want to switch this feature off and make all indentation, for example, two spaces, you'd do the following in your User Settings or Workspace settings.




                                  "editor.tabSize": 2,

                                  "editor.detectIndentation": false






                                  share|improve this answer




















                                  • 2





                                    And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                    – LoBo
                                    May 26 '17 at 14:48











                                  • ...why would you do that? Can't you just use the convert indentation command?

                                    – celticminstrel
                                    Aug 6 '18 at 16:04













                                  102












                                  102








                                  102







                                  By default, Visual Studio Code auto-detects the indentation of the current open file. If you want to switch this feature off and make all indentation, for example, two spaces, you'd do the following in your User Settings or Workspace settings.




                                  "editor.tabSize": 2,

                                  "editor.detectIndentation": false






                                  share|improve this answer















                                  By default, Visual Studio Code auto-detects the indentation of the current open file. If you want to switch this feature off and make all indentation, for example, two spaces, you'd do the following in your User Settings or Workspace settings.




                                  "editor.tabSize": 2,

                                  "editor.detectIndentation": false







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited Dec 15 '18 at 18:00









                                  Peter Mortensen

                                  14k1987114




                                  14k1987114










                                  answered Aug 8 '16 at 13:32









                                  Jim DoyleJim Doyle

                                  1,348177




                                  1,348177







                                  • 2





                                    And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                    – LoBo
                                    May 26 '17 at 14:48











                                  • ...why would you do that? Can't you just use the convert indentation command?

                                    – celticminstrel
                                    Aug 6 '18 at 16:04












                                  • 2





                                    And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                    – LoBo
                                    May 26 '17 at 14:48











                                  • ...why would you do that? Can't you just use the convert indentation command?

                                    – celticminstrel
                                    Aug 6 '18 at 16:04







                                  2




                                  2





                                  And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                  – LoBo
                                  May 26 '17 at 14:48





                                  And if you want to leave "editor.detectIdentation": true, but still change the identation from spaces to tabs, you need to remove all identation in your file, save and close it, then reopen and do Format document.

                                  – LoBo
                                  May 26 '17 at 14:48













                                  ...why would you do that? Can't you just use the convert indentation command?

                                  – celticminstrel
                                  Aug 6 '18 at 16:04





                                  ...why would you do that? Can't you just use the convert indentation command?

                                  – celticminstrel
                                  Aug 6 '18 at 16:04











                                  48














                                  We can control tab size by file type with EditorConfig and its Visual Studio Code extension. We then can make Alt + Shift + F specific to each file type.



                                  Installation



                                  ext install EditorConfig


                                  Example Configuration



                                  .editorconfig



                                  [*]
                                  indent_style = space

                                  [*.cs,js]
                                  indent_size = 4

                                  [*.json]
                                  indent_size = 2


                                  settings.json



                                  EditorConfig overrides whatever settings.json configures for the editor. There is no need to change editor.detectIndentation.






                                  share|improve this answer





























                                    48














                                    We can control tab size by file type with EditorConfig and its Visual Studio Code extension. We then can make Alt + Shift + F specific to each file type.



                                    Installation



                                    ext install EditorConfig


                                    Example Configuration



                                    .editorconfig



                                    [*]
                                    indent_style = space

                                    [*.cs,js]
                                    indent_size = 4

                                    [*.json]
                                    indent_size = 2


                                    settings.json



                                    EditorConfig overrides whatever settings.json configures for the editor. There is no need to change editor.detectIndentation.






                                    share|improve this answer



























                                      48












                                      48








                                      48







                                      We can control tab size by file type with EditorConfig and its Visual Studio Code extension. We then can make Alt + Shift + F specific to each file type.



                                      Installation



                                      ext install EditorConfig


                                      Example Configuration



                                      .editorconfig



                                      [*]
                                      indent_style = space

                                      [*.cs,js]
                                      indent_size = 4

                                      [*.json]
                                      indent_size = 2


                                      settings.json



                                      EditorConfig overrides whatever settings.json configures for the editor. There is no need to change editor.detectIndentation.






                                      share|improve this answer















                                      We can control tab size by file type with EditorConfig and its Visual Studio Code extension. We then can make Alt + Shift + F specific to each file type.



                                      Installation



                                      ext install EditorConfig


                                      Example Configuration



                                      .editorconfig



                                      [*]
                                      indent_style = space

                                      [*.cs,js]
                                      indent_size = 4

                                      [*.json]
                                      indent_size = 2


                                      settings.json



                                      EditorConfig overrides whatever settings.json configures for the editor. There is no need to change editor.detectIndentation.







                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Dec 15 '18 at 18:01









                                      Peter Mortensen

                                      14k1987114




                                      14k1987114










                                      answered Sep 9 '16 at 2:35









                                      Shaun LuttinShaun Luttin

                                      63.5k36239299




                                      63.5k36239299





















                                          6














                                          You want to make sure your editorconfig is not conflicting with your user or workspace settings configuration, as I just had a bit of annoyance thinking the settings files settings were not being applied when it was my editor configuration undoing those changes.






                                          share|improve this answer





























                                            6














                                            You want to make sure your editorconfig is not conflicting with your user or workspace settings configuration, as I just had a bit of annoyance thinking the settings files settings were not being applied when it was my editor configuration undoing those changes.






                                            share|improve this answer



























                                              6












                                              6








                                              6







                                              You want to make sure your editorconfig is not conflicting with your user or workspace settings configuration, as I just had a bit of annoyance thinking the settings files settings were not being applied when it was my editor configuration undoing those changes.






                                              share|improve this answer















                                              You want to make sure your editorconfig is not conflicting with your user or workspace settings configuration, as I just had a bit of annoyance thinking the settings files settings were not being applied when it was my editor configuration undoing those changes.







                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Dec 15 '18 at 18:02









                                              Peter Mortensen

                                              14k1987114




                                              14k1987114










                                              answered Mar 22 '17 at 16:22









                                              Travis BrownTravis Brown

                                              6618




                                              6618





















                                                  6














                                                  That is lonefy.vscode-js-css-html-formatter to blame. Disable it, and install HookyQR.beautify.



                                                  Now on save your tabs wouldn't be converted.






                                                  share|improve this answer





























                                                    6














                                                    That is lonefy.vscode-js-css-html-formatter to blame. Disable it, and install HookyQR.beautify.



                                                    Now on save your tabs wouldn't be converted.






                                                    share|improve this answer



























                                                      6












                                                      6








                                                      6







                                                      That is lonefy.vscode-js-css-html-formatter to blame. Disable it, and install HookyQR.beautify.



                                                      Now on save your tabs wouldn't be converted.






                                                      share|improve this answer















                                                      That is lonefy.vscode-js-css-html-formatter to blame. Disable it, and install HookyQR.beautify.



                                                      Now on save your tabs wouldn't be converted.







                                                      share|improve this answer














                                                      share|improve this answer



                                                      share|improve this answer








                                                      edited Dec 15 '18 at 18:05









                                                      Peter Mortensen

                                                      14k1987114




                                                      14k1987114










                                                      answered Jul 4 '17 at 22:03









                                                      user3550138user3550138

                                                      9112




                                                      9112





















                                                          3














                                                          In VSC version 1.31.1 or more (I think).
                                                          Like sed Alex Dima.
                                                          You can customize this easily via these settings for



                                                          • Windows in menu File → Preferences → User Settings or use short keys ctr + shift + p

                                                          • Mac in menu Code → Preferences → Settings or ⌘,

                                                          enter image description here



                                                          enter image description here






                                                          share|improve this answer



























                                                            3














                                                            In VSC version 1.31.1 or more (I think).
                                                            Like sed Alex Dima.
                                                            You can customize this easily via these settings for



                                                            • Windows in menu File → Preferences → User Settings or use short keys ctr + shift + p

                                                            • Mac in menu Code → Preferences → Settings or ⌘,

                                                            enter image description here



                                                            enter image description here






                                                            share|improve this answer

























                                                              3












                                                              3








                                                              3







                                                              In VSC version 1.31.1 or more (I think).
                                                              Like sed Alex Dima.
                                                              You can customize this easily via these settings for



                                                              • Windows in menu File → Preferences → User Settings or use short keys ctr + shift + p

                                                              • Mac in menu Code → Preferences → Settings or ⌘,

                                                              enter image description here



                                                              enter image description here






                                                              share|improve this answer













                                                              In VSC version 1.31.1 or more (I think).
                                                              Like sed Alex Dima.
                                                              You can customize this easily via these settings for



                                                              • Windows in menu File → Preferences → User Settings or use short keys ctr + shift + p

                                                              • Mac in menu Code → Preferences → Settings or ⌘,

                                                              enter image description here



                                                              enter image description here







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Feb 16 at 12:47









                                                              Andrey PatseikoAndrey Patseiko

                                                              35437




                                                              35437





















                                                                  3














                                                                  If you use the prettier extension in vscode, try adding this to the settings.json file:



                                                                  "editor.insertSpaces": false,
                                                                  "editor.tabSize": 4,
                                                                  "editor.detectIndentation": false,

                                                                  "prettier.tabWidth": 4,
                                                                  "prettier.useTabs": true // this made it finally work for me





                                                                  share|improve this answer



























                                                                    3














                                                                    If you use the prettier extension in vscode, try adding this to the settings.json file:



                                                                    "editor.insertSpaces": false,
                                                                    "editor.tabSize": 4,
                                                                    "editor.detectIndentation": false,

                                                                    "prettier.tabWidth": 4,
                                                                    "prettier.useTabs": true // this made it finally work for me





                                                                    share|improve this answer

























                                                                      3












                                                                      3








                                                                      3







                                                                      If you use the prettier extension in vscode, try adding this to the settings.json file:



                                                                      "editor.insertSpaces": false,
                                                                      "editor.tabSize": 4,
                                                                      "editor.detectIndentation": false,

                                                                      "prettier.tabWidth": 4,
                                                                      "prettier.useTabs": true // this made it finally work for me





                                                                      share|improve this answer













                                                                      If you use the prettier extension in vscode, try adding this to the settings.json file:



                                                                      "editor.insertSpaces": false,
                                                                      "editor.tabSize": 4,
                                                                      "editor.detectIndentation": false,

                                                                      "prettier.tabWidth": 4,
                                                                      "prettier.useTabs": true // this made it finally work for me






                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Feb 23 at 20:04









                                                                      slowpoke123slowpoke123

                                                                      709




                                                                      709





















                                                                          3














                                                                          In your bottom-right corner, you have Spaces:
                                                                          Spaces: 2



                                                                          There you can change the indentation according to your needs:
                                                                          Indentation Options






                                                                          share|improve this answer



























                                                                            3














                                                                            In your bottom-right corner, you have Spaces:
                                                                            Spaces: 2



                                                                            There you can change the indentation according to your needs:
                                                                            Indentation Options






                                                                            share|improve this answer

























                                                                              3












                                                                              3








                                                                              3







                                                                              In your bottom-right corner, you have Spaces:
                                                                              Spaces: 2



                                                                              There you can change the indentation according to your needs:
                                                                              Indentation Options






                                                                              share|improve this answer













                                                                              In your bottom-right corner, you have Spaces:
                                                                              Spaces: 2



                                                                              There you can change the indentation according to your needs:
                                                                              Indentation Options







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Mar 22 at 13:33









                                                                              DacomisDacomis

                                                                              314




                                                                              314





















                                                                                  2














                                                                                  If the accepted answer on this post doesn't work, give this a try:



                                                                                  I had EditorConfig for Visual Studio Code installed in my editor, and it kept overriding my user settings which were set to indent files using spaces. Every time I switched between editor tabs, my file would automatically get indented with tabs even if I had converted indentation to spaces!!!



                                                                                  Right after I uninstalled this extension, indentation no longer changes between switching editor tabs, and I can work more comfortably rather than having to manually convert tabs to spaces every time I switch files - that is painful.






                                                                                  share|improve this answer

























                                                                                  • this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                    – Esteban
                                                                                    Feb 20 at 20:12















                                                                                  2














                                                                                  If the accepted answer on this post doesn't work, give this a try:



                                                                                  I had EditorConfig for Visual Studio Code installed in my editor, and it kept overriding my user settings which were set to indent files using spaces. Every time I switched between editor tabs, my file would automatically get indented with tabs even if I had converted indentation to spaces!!!



                                                                                  Right after I uninstalled this extension, indentation no longer changes between switching editor tabs, and I can work more comfortably rather than having to manually convert tabs to spaces every time I switch files - that is painful.






                                                                                  share|improve this answer

























                                                                                  • this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                    – Esteban
                                                                                    Feb 20 at 20:12













                                                                                  2












                                                                                  2








                                                                                  2







                                                                                  If the accepted answer on this post doesn't work, give this a try:



                                                                                  I had EditorConfig for Visual Studio Code installed in my editor, and it kept overriding my user settings which were set to indent files using spaces. Every time I switched between editor tabs, my file would automatically get indented with tabs even if I had converted indentation to spaces!!!



                                                                                  Right after I uninstalled this extension, indentation no longer changes between switching editor tabs, and I can work more comfortably rather than having to manually convert tabs to spaces every time I switch files - that is painful.






                                                                                  share|improve this answer















                                                                                  If the accepted answer on this post doesn't work, give this a try:



                                                                                  I had EditorConfig for Visual Studio Code installed in my editor, and it kept overriding my user settings which were set to indent files using spaces. Every time I switched between editor tabs, my file would automatically get indented with tabs even if I had converted indentation to spaces!!!



                                                                                  Right after I uninstalled this extension, indentation no longer changes between switching editor tabs, and I can work more comfortably rather than having to manually convert tabs to spaces every time I switch files - that is painful.







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited Dec 15 '18 at 18:11









                                                                                  Peter Mortensen

                                                                                  14k1987114




                                                                                  14k1987114










                                                                                  answered Jul 25 '18 at 23:16









                                                                                  dhruvpateldhruvpatel

                                                                                  7511823




                                                                                  7511823












                                                                                  • this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                    – Esteban
                                                                                    Feb 20 at 20:12

















                                                                                  • this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                    – Esteban
                                                                                    Feb 20 at 20:12
















                                                                                  this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                  – Esteban
                                                                                  Feb 20 at 20:12





                                                                                  this was it for me.no matter how i changed my settings, every time i opened the file it would revert.

                                                                                  – Esteban
                                                                                  Feb 20 at 20:12











                                                                                  1














                                                                                  @alex-dima's solution from 2015 will change tab sizes and spaces for all files and @Tricky's solution from 2016 appears to only change the settings for the current file.



                                                                                  As of 2017, I found another solution that works on a per-language basis. Visual Studio Code was not using the proper tab sizes or space settings for Elixir, so I found that I could change the settings for all Elixir files.



                                                                                  I clicked on the language in the status bar ("Elixir" in my case), chose "Configure 'Elixir' language based settings...", and edited the Elixir-specific language settings. I just copied the "editor.tabSize" and "editor.insertSpaces" settings from the default settings on the left (I'm so glad those are shown) and then modified them on the right.



                                                                                  It worked great, and now all Elixir language files use the proper tab size and space settings.






                                                                                  share|improve this answer



























                                                                                    1














                                                                                    @alex-dima's solution from 2015 will change tab sizes and spaces for all files and @Tricky's solution from 2016 appears to only change the settings for the current file.



                                                                                    As of 2017, I found another solution that works on a per-language basis. Visual Studio Code was not using the proper tab sizes or space settings for Elixir, so I found that I could change the settings for all Elixir files.



                                                                                    I clicked on the language in the status bar ("Elixir" in my case), chose "Configure 'Elixir' language based settings...", and edited the Elixir-specific language settings. I just copied the "editor.tabSize" and "editor.insertSpaces" settings from the default settings on the left (I'm so glad those are shown) and then modified them on the right.



                                                                                    It worked great, and now all Elixir language files use the proper tab size and space settings.






                                                                                    share|improve this answer

























                                                                                      1












                                                                                      1








                                                                                      1







                                                                                      @alex-dima's solution from 2015 will change tab sizes and spaces for all files and @Tricky's solution from 2016 appears to only change the settings for the current file.



                                                                                      As of 2017, I found another solution that works on a per-language basis. Visual Studio Code was not using the proper tab sizes or space settings for Elixir, so I found that I could change the settings for all Elixir files.



                                                                                      I clicked on the language in the status bar ("Elixir" in my case), chose "Configure 'Elixir' language based settings...", and edited the Elixir-specific language settings. I just copied the "editor.tabSize" and "editor.insertSpaces" settings from the default settings on the left (I'm so glad those are shown) and then modified them on the right.



                                                                                      It worked great, and now all Elixir language files use the proper tab size and space settings.






                                                                                      share|improve this answer













                                                                                      @alex-dima's solution from 2015 will change tab sizes and spaces for all files and @Tricky's solution from 2016 appears to only change the settings for the current file.



                                                                                      As of 2017, I found another solution that works on a per-language basis. Visual Studio Code was not using the proper tab sizes or space settings for Elixir, so I found that I could change the settings for all Elixir files.



                                                                                      I clicked on the language in the status bar ("Elixir" in my case), chose "Configure 'Elixir' language based settings...", and edited the Elixir-specific language settings. I just copied the "editor.tabSize" and "editor.insertSpaces" settings from the default settings on the left (I'm so glad those are shown) and then modified them on the right.



                                                                                      It worked great, and now all Elixir language files use the proper tab size and space settings.







                                                                                      share|improve this answer












                                                                                      share|improve this answer



                                                                                      share|improve this answer










                                                                                      answered Nov 29 '17 at 23:16









                                                                                      Kevin PeterKevin Peter

                                                                                      23645




                                                                                      23645





















                                                                                          1














                                                                                          Menu FilePreferencesSettings



                                                                                          Add to user settings:



                                                                                          "editor.tabSize": 2,
                                                                                          "editor.detectIndentation": false


                                                                                          then right click your document if you have one opened already and click Format Document to have your existing document follow these new settings.






                                                                                          share|improve this answer





























                                                                                            1














                                                                                            Menu FilePreferencesSettings



                                                                                            Add to user settings:



                                                                                            "editor.tabSize": 2,
                                                                                            "editor.detectIndentation": false


                                                                                            then right click your document if you have one opened already and click Format Document to have your existing document follow these new settings.






                                                                                            share|improve this answer



























                                                                                              1












                                                                                              1








                                                                                              1







                                                                                              Menu FilePreferencesSettings



                                                                                              Add to user settings:



                                                                                              "editor.tabSize": 2,
                                                                                              "editor.detectIndentation": false


                                                                                              then right click your document if you have one opened already and click Format Document to have your existing document follow these new settings.






                                                                                              share|improve this answer















                                                                                              Menu FilePreferencesSettings



                                                                                              Add to user settings:



                                                                                              "editor.tabSize": 2,
                                                                                              "editor.detectIndentation": false


                                                                                              then right click your document if you have one opened already and click Format Document to have your existing document follow these new settings.







                                                                                              share|improve this answer














                                                                                              share|improve this answer



                                                                                              share|improve this answer








                                                                                              edited Dec 15 '18 at 18:08









                                                                                              Peter Mortensen

                                                                                              14k1987114




                                                                                              14k1987114










                                                                                              answered Jan 24 '18 at 20:39









                                                                                              Gmoney MozartGmoney Mozart

                                                                                              311




                                                                                              311





















                                                                                                  1














                                                                                                  When using TypeScript, the default tab width is always two regardless of what it says in the toolbar. You have to set "prettier.tabWidth" in your user settings to change it.



                                                                                                  Ctrl + P, Type → user settings, add:



                                                                                                  "prettier.tabWidth": 4





                                                                                                  share|improve this answer





























                                                                                                    1














                                                                                                    When using TypeScript, the default tab width is always two regardless of what it says in the toolbar. You have to set "prettier.tabWidth" in your user settings to change it.



                                                                                                    Ctrl + P, Type → user settings, add:



                                                                                                    "prettier.tabWidth": 4





                                                                                                    share|improve this answer



























                                                                                                      1












                                                                                                      1








                                                                                                      1







                                                                                                      When using TypeScript, the default tab width is always two regardless of what it says in the toolbar. You have to set "prettier.tabWidth" in your user settings to change it.



                                                                                                      Ctrl + P, Type → user settings, add:



                                                                                                      "prettier.tabWidth": 4





                                                                                                      share|improve this answer















                                                                                                      When using TypeScript, the default tab width is always two regardless of what it says in the toolbar. You have to set "prettier.tabWidth" in your user settings to change it.



                                                                                                      Ctrl + P, Type → user settings, add:



                                                                                                      "prettier.tabWidth": 4






                                                                                                      share|improve this answer














                                                                                                      share|improve this answer



                                                                                                      share|improve this answer








                                                                                                      edited Dec 15 '18 at 18:10









                                                                                                      Peter Mortensen

                                                                                                      14k1987114




                                                                                                      14k1987114










                                                                                                      answered Jul 12 '18 at 15:16









                                                                                                      Steve HanovSteve Hanov

                                                                                                      5,911154859




                                                                                                      5,911154859





















                                                                                                          0














                                                                                                          User3550138 is correct. lonefy.vscode-js-css-html-formatter overrides all the settings mentioned in other answers. However, you don't have to disable or uninstall it as it can be configured.



                                                                                                          Full instructions can be found by opening the extensions sidebar and clicking on this extension and it will display configuration instructions in the editor workspace. At least it does for me in Visual Studio Code version 1.14.1.






                                                                                                          share|improve this answer





























                                                                                                            0














                                                                                                            User3550138 is correct. lonefy.vscode-js-css-html-formatter overrides all the settings mentioned in other answers. However, you don't have to disable or uninstall it as it can be configured.



                                                                                                            Full instructions can be found by opening the extensions sidebar and clicking on this extension and it will display configuration instructions in the editor workspace. At least it does for me in Visual Studio Code version 1.14.1.






                                                                                                            share|improve this answer



























                                                                                                              0












                                                                                                              0








                                                                                                              0







                                                                                                              User3550138 is correct. lonefy.vscode-js-css-html-formatter overrides all the settings mentioned in other answers. However, you don't have to disable or uninstall it as it can be configured.



                                                                                                              Full instructions can be found by opening the extensions sidebar and clicking on this extension and it will display configuration instructions in the editor workspace. At least it does for me in Visual Studio Code version 1.14.1.






                                                                                                              share|improve this answer















                                                                                                              User3550138 is correct. lonefy.vscode-js-css-html-formatter overrides all the settings mentioned in other answers. However, you don't have to disable or uninstall it as it can be configured.



                                                                                                              Full instructions can be found by opening the extensions sidebar and clicking on this extension and it will display configuration instructions in the editor workspace. At least it does for me in Visual Studio Code version 1.14.1.







                                                                                                              share|improve this answer














                                                                                                              share|improve this answer



                                                                                                              share|improve this answer








                                                                                                              edited Dec 15 '18 at 18:06









                                                                                                              Peter Mortensen

                                                                                                              14k1987114




                                                                                                              14k1987114










                                                                                                              answered Jul 15 '17 at 1:12









                                                                                                              DRLDRL

                                                                                                              11




                                                                                                              11





















                                                                                                                  0














                                                                                                                  If this is for Angular 2, and the CLI is generating files which you would like differently formatted, you can edit these files to change what is generated:



                                                                                                                  npm_modules/@angular/cli/blueprints/component/files/__path__/*


                                                                                                                  Not massively recommended as an npm update will delete your work, but it has saved me a lot of time.






                                                                                                                  share|improve this answer





























                                                                                                                    0














                                                                                                                    If this is for Angular 2, and the CLI is generating files which you would like differently formatted, you can edit these files to change what is generated:



                                                                                                                    npm_modules/@angular/cli/blueprints/component/files/__path__/*


                                                                                                                    Not massively recommended as an npm update will delete your work, but it has saved me a lot of time.






                                                                                                                    share|improve this answer



























                                                                                                                      0












                                                                                                                      0








                                                                                                                      0







                                                                                                                      If this is for Angular 2, and the CLI is generating files which you would like differently formatted, you can edit these files to change what is generated:



                                                                                                                      npm_modules/@angular/cli/blueprints/component/files/__path__/*


                                                                                                                      Not massively recommended as an npm update will delete your work, but it has saved me a lot of time.






                                                                                                                      share|improve this answer















                                                                                                                      If this is for Angular 2, and the CLI is generating files which you would like differently formatted, you can edit these files to change what is generated:



                                                                                                                      npm_modules/@angular/cli/blueprints/component/files/__path__/*


                                                                                                                      Not massively recommended as an npm update will delete your work, but it has saved me a lot of time.







                                                                                                                      share|improve this answer














                                                                                                                      share|improve this answer



                                                                                                                      share|improve this answer








                                                                                                                      edited Dec 15 '18 at 18:07









                                                                                                                      Peter Mortensen

                                                                                                                      14k1987114




                                                                                                                      14k1987114










                                                                                                                      answered Sep 29 '17 at 12:53









                                                                                                                      Ben TaliadorosBen Taliadoros

                                                                                                                      3,163114575




                                                                                                                      3,163114575





















                                                                                                                          0














                                                                                                                          I tried to change editor.tabSize to 4, but .editorConfig overrides whatever settings I had specified, so there is no need to change any configuration in user settings. You just need to edit .editorConfig file:



                                                                                                                          set indent_size = 4





                                                                                                                          share|improve this answer





























                                                                                                                            0














                                                                                                                            I tried to change editor.tabSize to 4, but .editorConfig overrides whatever settings I had specified, so there is no need to change any configuration in user settings. You just need to edit .editorConfig file:



                                                                                                                            set indent_size = 4





                                                                                                                            share|improve this answer



























                                                                                                                              0












                                                                                                                              0








                                                                                                                              0







                                                                                                                              I tried to change editor.tabSize to 4, but .editorConfig overrides whatever settings I had specified, so there is no need to change any configuration in user settings. You just need to edit .editorConfig file:



                                                                                                                              set indent_size = 4





                                                                                                                              share|improve this answer















                                                                                                                              I tried to change editor.tabSize to 4, but .editorConfig overrides whatever settings I had specified, so there is no need to change any configuration in user settings. You just need to edit .editorConfig file:



                                                                                                                              set indent_size = 4






                                                                                                                              share|improve this answer














                                                                                                                              share|improve this answer



                                                                                                                              share|improve this answer








                                                                                                                              edited Dec 15 '18 at 18:09









                                                                                                                              Peter Mortensen

                                                                                                                              14k1987114




                                                                                                                              14k1987114










                                                                                                                              answered Jun 8 '18 at 13:32









                                                                                                                              Gh111Gh111

                                                                                                                              24754




                                                                                                                              24754



























                                                                                                                                  draft saved

                                                                                                                                  draft discarded
















































                                                                                                                                  Thanks for contributing an answer to Stack Overflow!


                                                                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                                                                  But avoid


                                                                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                                                                                                  To learn more, see our tips on writing great answers.




                                                                                                                                  draft saved


                                                                                                                                  draft discarded














                                                                                                                                  StackExchange.ready(
                                                                                                                                  function ()
                                                                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29972396%2fhow-to-customize-the-tab-to-space-conversion-factor-when-using-visual-studio-cod%23new-answer', 'question_page');

                                                                                                                                  );

                                                                                                                                  Post as a guest















                                                                                                                                  Required, but never shown





















































                                                                                                                                  Required, but never shown














                                                                                                                                  Required, but never shown












                                                                                                                                  Required, but never shown







                                                                                                                                  Required, but never shown

































                                                                                                                                  Required, but never shown














                                                                                                                                  Required, but never shown












                                                                                                                                  Required, but never shown







                                                                                                                                  Required, but never shown







                                                                                                                                  Popular posts from this blog

                                                                                                                                  Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                                                                                                                  SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                                                                                                  Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript