Sublime Forum

Arbitrarily large tab sizes for viewing columnar data

#1

I’ve googled a lot on setting tab sizes, and it’s all about per file type, platform etc.

What I want is to, occasionally, set a very large tab size, e.g. 16 or 20. The reason is for viewing text files of columnar data with large floating point values. You want to make the tabs big enough that the columns line up.

I used to be able to select a tab size of 16 from the menu, but this was removed. Now I’m not sure how to select, temporarily, for the currently loaded file, an arbitrarily large tab size.

Help!

Thanks,
Thomas Blom in Austin, TX

0 Likes

#2

There are a couple of ways for you to go, depending on how much effort you want to expend/how often you need to do this. The setting you want to modify is tab_size. This is a per view setting, so it’s automatically temporary to the view you do it in.

You can change the setting for a particular view by opening the console (default: Ctrl+` or View->Show Console) and execute something like this while your desired file has the input focus:

view.settings ().set ("tab_size", 20)

If you do this semi-regularly, then you can set up a key binding to do it for you. Such a binding would look like this, although you probably want to pick a combination that’s less of a contortion of the hands (and maybe one to put it back to what you normally use, if that matters):

{
    "keys": ["ctrl+alt+shift+tab"],
    "command": "set_setting",
    "args":
    {
        "setting": "tab_size",
        "value": 20
    }
}

Alternatively, you could add the command to the menu system. For example, if you had something like this in a file named Context.sublime-menu in your User package (use Preferences->Browse Packages to get at the User package directory), then the command will appear in the context menu when you right click on a file, and will appear checked when the tab size is currently 20:

[
    {
        "caption": "Tab Width: 20",
        "command": "set_setting",
        "args": {
            "setting": "tab_size",
            "value": 20
        },
        "checkbox": true
    }
]
5 Likes

#3

Thanks so much for the great answer. Perfect for what I need.

-t

0 Likes