崇高文字2中括号(括号)的智能缩进 [英] Smart Indenting of brackets (parenthesis) in sublime text 2

查看:111
本文介绍了崇高文字2中括号(括号)的智能缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常棒的设置,可以从崇高的文本2内编辑和运行maxscript.

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

抱歉-Chrome决定我不在时完成编辑((

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

如果我键入if (x) then {,那么enter我将得到一个格式正确的块,插入符号现在位于箭头上

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 (
    <-)

推荐答案

我发现它在大括号中的位置,只是在默认键绑定中.我复制了"keys": ["enter"]部分,并用("而不是"{"代替了正则表达式.

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 "{".

我还必须复制内置的AddLineInBraces.sublime-macro并向其中添加{"command": "left_delete" },:

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} }
]

如果正则表达式匹配,则使Enter按键调用该宏.这给出了完美的结果!

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

我实际上最近一次减少了MXS的使用,因此并没有真正去做很多事情.

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.

为回答 FrozenKiwi ,我将来自不同地方的一些插件混在一起,以便可以从ST2将maxscript发送到Max. 此处是链接繁重的工作.确实需要一些工作才能使其运行,但确实非常方便.

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.

其余的只是各种ST2优点的点点滴滴:Shift + Enter评估选择,Ctrl + E评估全部,很多(和很多)宏,例如"for" +标签将写为format "var: %\n" (var as string)

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.

我唯一剩下的障碍是无法将maxscript侦听器的输出重定向到ST2,我拖网了互联网,似乎还没有人这样做,我也不愿意亲自尝试.我什至不知道Maxscript本身是否可以使用-它可能必须是使用SDK的C ++插件-但到目前为止,我对C ++插件的经验很少.我毫不怀疑可以做到.

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.

这篇关于崇高文字2中括号(括号)的智能缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆