How can I stop VS code from converting tabs to spaces in a particular file?

Viewed 60

In the VS code editor, the default setting is to replace tabs by spaces, which is what I want. However, this is disastrous in a make file. I have written a make file (named Makefile) but VS code insists on changing tabs to spaces so I get a "Missing Separator" error when I run make.

If I go to File > Preferences > Settings and type @id:editor.insertSpaces in the menu, I see this:

settings, editor: insert spaces, modified elsewhere

When I click on Modified elsewhere I see this:

enter image description here

The second screenshot seems to says that the editor won't insert spaces in a Makefile, but it certainly is. What am I doing wrong, or what have I failed to do?

2 Answers

Try modifing settings.json

VScode Settings

VScode JSON settings

There are 3 levels (by higher priority)
  1. Worspace Settings JSON
  2. User Settings JSON
  3. Default Settings JSON

This should fix most inconveniences:

    "[markdown]": {
        "files.trimTrailingWhitespace": false,
        "editor.insertSpaces": false
    },

What worked for me was adding the following to settings.json:

"[makefile]": {
        "editor.insertSpaces": false
    },
Related