Question

I've got a pretty sweet setup for editing and running maxscript from inside sublime text 2.

The one thing I've been wanting recently is to emulate or copy the behaviour of the curly brackets with the normal round brackets

EDIT: Sorry - Chrome decided I was finished editing there when I wasn't :(

If I type if (x) then { then enter I will get a nicely formatted block, with the caret now at the arrow

if(x) then {
    <-
}

but I cant find where sublime text is hiding it.

I want to copy this behaviour to the normal round brackets () instead of getting

if (x) then (
    <-)
Was it helpful?

Solution

I've found where it does this on curly brackets, it's simply in the default key bindings. I copied the section "keys": ["enter"] and replaced the regex with "(" instead of "{".

I also had to copy the built in AddLineInBraces.sublime-macro and add {"command": "left_delete" }, to it:

[
    {"command": "insert", "args": {"characters": "\n\n"} },
    {"command": "left_delete" },
    {"command": "move", "args": {"by": "lines", "forward": false} },
    {"command": "move_to", "args": {"to": "hardeol", "extend": false} },
    {"command": "reindent", "args": {"single_line": true} }
]

And make the enter keystroke call that macro if the regex matches. This gives the perfect result!

I've actually been doing less MXS the last while so haven't really been playing with it much.

Thanks to Ghoul Fool for the suggestions but after having a look I wanted a simpler solution.

In answer to FrozenKiwi, I have mashed together a few plugins from various places so I can send maxscript to Max from ST2. Here is a link for the heavy lifting. It does involve some work to get it running but is very handy indeed.

The rest is all just dribs and drabs of various ST2 goodness: shift+enter to evaluate selection, ctrl+e to evaluate all, lots (and lots) of macros e.g. "for" + tab will write format "var: %\n" (var as string)

I don't know if I can release it as a package as it's taken from quite a few different sources. I could check the licensing for each thing though I suppose.

My only remaining hurdle is not being able to redirect output from the maxscript listener to ST2, I've trawled the internet and nobody seems to have done it yet, and I'm not keen on trying it myself. I don't even know if Maxscript itself can be used - it might have to be a C++ plugin using the SDK - but my experience thus far with C++ plugins is minimal. I don't doubt it can be done though.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top