Still Fixing Sublime

Minor notes on customization, all files are in Preferences > Browse Packages.

I fixed Dracula to be a little more pit of utter darkness:

UI: Customize Theme, file is User/Default Dark.sublime-theme:

// Documentation at https://www.sublimetext.com/docs/themes.html
{
    "variables": {
        "base_hue": "black",
        "base_tint": "#99ddff",
        "ui_bg": "#222222",
        "text_fg": "white",
        "sidebar_bg": "#111111",
        "sidebar_row_selected": "#666600",
    },
    "rules": [
    ]
}

UI: Customize Color Scheme, file is User/Dracula.sublime-color-scheme:

// Documentation at https://www.sublimetext.com/docs/color_schemes.html
{
    "variables": {
    },
    "globals": {
        "background": "black",
    },
    "rules": [
    ]
}

And some keys I use, file is User/Default (OSX).sublime-keymap: ^O as Open above is incredibly useful if you write "paren code enter paren open-above tab" over and over. Cmd-Y is lambda λ in a bunch of my editors and iTerm2; using the actual lambda symbol is awkward but cool, so of course I do it.

[
    { "keys": ["ctrl+o"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line Before.sublime-macro"} },
    { "keys": ["shift+ctrl+o"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} },
    { "keys": ["super+y"], "command": "insert", "args": {"characters": "λ"} },
]

Obvious missing feature is piping thru shell. I'm going to tackle that fully later, but for now I just needed to number lines, so added a package Number, containing:

Number/Number.py:

import sublime
import sublime_plugin

def numberLines(s):
    out = []
    i = 0
    for line in s.splitlines():
        i += 1
        out.append("%d. %s" % (i, line))
    return "\n".join(out) + "\n"

class NumberCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        for region in self.view.sel():
            if not region.empty():
                s = self.view.substr(region)
                out = numberLines(s)
                self.view.replace(edit, region, out)

and Number/Default (OSX).sublime-keymap:

[
    { "keys": ["shift+ctrl+n"], "command": "number" }
]

This makes a nice template for doing additional filters. Of course there's no damned examples for the current version, the old samples are missing arguments.

When developing a plugin, you can open the console with ^~ and type view.run_command("number") and see some print statement debugging, which helps.

It's very much more of a "developer's toolkit" than a real editor sometimes. It reminds me a lot of hacking on E/PM in REXX on OS/2, where the entire editor was just a big REXX script and it was trivial to make it circle all search results, or some such. But it's been better for doing my Scheme hacking than anything else so far.

%d bloggers like this: