Brackets: Set options for Tabs/Spaces on a per-extension basis

Created on 27 Mar 2014  路  5Comments  路  Source: adobe/brackets

I work a lot in Node/Express and it is becoming quite a pain to keep getting the "use tabs or spaces, not both" error in every .jade file I use. It's very nice to have the Tabs/Spaces option in the bottom of the editor, but it's becoming a pain to have to set the option every time I change files. Would it be possible to add an option (maybe in brackets.json) to determine whether a specific extension uses tabs or spaces and how many spaces that is?

Most helpful comment

Yes, this just became possible in Sprint 37 with the new preferences improvements using the "path" setting. Create a .brackets.json file and put it in the root of your project. Below is a sample project prefs file that uses different indent and word wrapping for different file extensions:

{
    "defaultExtension": "js",
    "path": {
        "*.htm": {
            "spaceUnits": 2
        },
        "*.html": {
            "spaceUnits": 2
        },
        "*.xml": {
            "spaceUnits": 2
        },
        "*.php": {
            "spaceUnits": 2
        },
        "*.txt": {
            "spaceUnits": 2,
            "wordWrap": true
        }
    },
    "wordWrap": false,
    "spaceUnits": 4,
    "useTabChar": true,
    "smartIndent": true,
    "softTabs": true
}

Note that "path" currently only works in project prefs files, not in global brackets.json prefs file -- we should be adding that soon.

All 5 comments

Yes, this just became possible in Sprint 37 with the new preferences improvements using the "path" setting. Create a .brackets.json file and put it in the root of your project. Below is a sample project prefs file that uses different indent and word wrapping for different file extensions:

{
    "defaultExtension": "js",
    "path": {
        "*.htm": {
            "spaceUnits": 2
        },
        "*.html": {
            "spaceUnits": 2
        },
        "*.xml": {
            "spaceUnits": 2
        },
        "*.php": {
            "spaceUnits": 2
        },
        "*.txt": {
            "spaceUnits": 2,
            "wordWrap": true
        }
    },
    "wordWrap": false,
    "spaceUnits": 4,
    "useTabChar": true,
    "smartIndent": true,
    "softTabs": true
}

Note that "path" currently only works in project prefs files, not in global brackets.json prefs file -- we should be adding that soon.

Note: for more details, see the documentation here: https://github.com/adobe/brackets/wiki/How-to-Use-Brackets#preferences

@dangoor, seems like this issue is already addressed, unless we are thinking about adding programming language specific preferences.

This already works and/or is a dupe of https://github.com/adobe/brackets/issues/6558.

Yes, this works today as described by Randy

Was this page helpful?
0 / 5 - 0 ratings