Sublime Forum

Please help me keep Sublime Text 2!

#1

Hello, here’s my problem in a nutshell:

Love SublimeText 2, bought it, been using it now for months. However I came from Textmate and now that there’s an alpha of Textmate2 out I find myself drifting back because of a couple of things I really like in Textmate. If some kind souls could point me in the right direction to replicate the Textmate features in Sublime I’d be ever so grateful. Mainly:

Highlight matching pairs of parentheses or brackets

Textmate autocompletion: invoked by Escape key (can’t find where to change that in the ST2 prefs) and hitting the key again cycles through completion list

Better completion (in Textmate on a Ruby doc, hitting ‘#’ inside double quotes will automatically make it ‘#{}’. And typing ‘<%=’ will close it with a ‘%>’. These are small but wonderful improvements)

Better undo. With SublimeCode Intel installed, undo in ST2 is one character at a time!

Bundle expansion: Under Bundles-> Ruby on Rails-> Models there is a whole list of often used commands to insert or tools to use, this would be great in ST2.

I’ll start with these so as not to get crazy. Thanks in advance.

0 Likes

Bracket underline in build 2051, can it be set to highlight?
#2

Allow me to refer you to github.com/facelessuser/BracketHighlighter which is available through Package Control.

SublimeCodeIntel allows you to cycle through an autocompletion list with ctrl+space.

0 Likes

#3

[quote=“skaet”]Allow me to refer you to github.com/facelessuser/BracketHighlighter which is available through Package Control.

SublimeCodeIntel allows you to cycle through an autocompletion list with ctrl+space.[/quote]

Thanks, I’ve downloaded BracketHighlighter, but it doesn’t behave as Textmate does where it highlights the brackets in a clear yellow solid colour. It seems to put an underscore on them (something recent versions of ST2 already did) but the solid option, though turned on in the prefs, does not work for me.

Also, CodeIntel I had to disable due to the undo problem.

0 Likes

#4

I use SublimeBrackets for this type of thing - github.com/pyparadigm/SublimeBrackets

Cheers
Lee

0 Likes

#5

BracketHighlighter only does the style you set in the settings

//Outline? (solid/outline/underline/none) -> "quote_style" : "solid", "curly_style" : "solid", "round_style" : "solid", "square_style": "solid", "angle_style" : "solid", "tag_style" : "outline",

If you are getting underlining as well as colored blocks, it is because you have ST2’s version of bracket highlighting enabled as well. You can turn off ST2’s default bracket matching, and use just BracketHighlighters, and then configure BracketHighlighter to the style and color you prefer.

Originally I used SublimeBrackets as well, but it will bog down the editor with its current implementation in large files; this is an outstanding issue that I could not live with. BracketHighlighter is a fork of SublimeBrackets and SublimeTagmatcher that fixes these performance issues and adds new features. I never got a response back from pyparadigm about the performance issue which is why I decided to create BracketHighlighter. By no means am I saying you need to switch to BracketHighlighter, but I wanted to illustrate why there are two different highlight packages, and illustrate why SublimeBrackets will not give you extremely different results since BracketHighlighter and SublimeBrackets both have the same origin. BracketHighlighter streamlined the matching processes into one that will not bog down your system and cause your typing and selecting to stutter.

0 Likes

#6

Check out the Textmate autocomplete plugin: https://github.com/alexstaubo/sublime_text_alternative_autocompletion

[quote]Better completion (in Textmate on a Ruby doc, hitting ‘#’ inside double quotes will automatically make it ‘#{}’. And typing ‘<%=’ will close it with a ‘%>’. These are small but wonderful improvements)
[/quote]

For the ruby completion, add this to your User key-bindings: { "args": { "contents": "#{${0:$SELECTION}}" }, "command": "insert_snippet", "context": { "key": "selector", "match_all": true, "operand": "string.quoted.double.ruby", "operator": "equal" } ], "keys": "#" ] },

This has been fixed in the lastest dev build.

0 Likes

#7

[quote=“facelessuser”]

Originally I used SublimeBrackets as well, but it will bog down the editor with its current implementation in large files; this is an outstanding issue that I could not live with. BracketHighlighter is a fork of SublimeBrackets and SublimeTagmatcher that fixes these performance issues and adds new features. I never got a response back from pyparadigm about the performance issue which is why I decided to create BracketHighlighter. By no means am I saying you need to switch to BracketHighlighter, but I wanted to illustrate why there are two different highlight packages, and illustrate why SublimeBrackets will not give you extremely different results since BracketHighlighter and SublimeBrackets both have the same origin. BracketHighlighter streamlined the matching processes into one that will not bog down your system and cause your typing and selecting to stutter.[/quote]

Ah, I didn’t know this. Many thanks for the info. I am new to Sublime Text (3 days and counting) so just getting my head around the different plugins.

L

0 Likes

#8

[quote=“C0D312”]
For the ruby completion, add this to your User key-bindings:[/quote]

Superb! Thanks. What about getting it to close the <%= and <% tags, how can I accomplish that?

Dev build of ST2 or SublimeCodeIntel? I’ve got the latest ST2 (just updated right now) I installed SCI from ST2’s package manager, should I get it from Github instead?

0 Likes

#9

Aha, installing the plugin from github instead of using the Package Manager within sublime has actually done the trick!

My next question is how to change the colour of the highlights? I don’t see it anywhere in the prefs.

Thanks.

0 Likes

#10

Terrific! Thanks so much, this has REALLY been bothering me for a long time, I just didn’t have time to hunt around. Now I am much happier :smiley:

To close the <% I guess I could create my own snippets, just wondering if there is a better way to do it.

0 Likes

#11

I hate to sound stupid, but I’m not having any luck creating a snippet for <% to create and close the tags. Any pointers would be appreciated.

thanks.

0 Likes

#12

Try this (add it to your user keybindings):

{ "args": { "contents": "=$0%>" }, "command": "insert_snippet", "context": { "key": "selector", "match_all": true, "operand": "source.ruby", "operator": "equal" }, { "key": "preceding_text", "operator": "regex_contains", "operand": "<%", "match_all": true } ], "keys": "=" ] }

0 Likes

#13

COD312, thanks a lot this works perfectly, I really appreciate it.

Now, if I may try your patience I’m trying to accomplish the same thing for <% so I have this code:

{ "args": { "contents": "% $0 %>" }, "command": "insert_snippet", "context": { "key": "selector", "match_all": true, "operand": "source.ruby", "operator": "equal" }, { "key": "preceding_text", "operator": "regex_contains", "operand": "<", "match_all": true } ], "keys": "%" ] }
Could you tell me what I’m doing wrong here?

0 Likes

#14

What seems to be the problem? I just copied and pasted your code and it seems to work fine.

0 Likes

#15

Well, this one works <%=

But just typing this <% will not create the closing brackets. You say it’s working for you? It creates the %> after typing <% ?

0 Likes

#16

Another problem I have is that any time I type an equal sign it adds %>. I only want the closing bracket if the equal sign is preceded by <

Let me clarify, it does this while inside a <%= when I try to type something like ‘:controller =>’ because of course it’s matching the ‘<%=’ from the beginning of the line. Just wondering if there is a way to avoid this.

0 Likes

#17

Take a look at github.com/kevinansfield/SublimeERB – it adds a ERB-Block command similar to that of Textmate.

0 Likes

#18

I use this all the time – really handy command. It won’t auto close your <% like you’re asking, but once you get accustomed to ctrl-shift-period to quickly insert a <%= %> block (and cycle through the variations thereof), it’s much faster than manually typing the starting <%.

0 Likes

#19

If you’re not content with sublimeERB, you can try this keybinding:

{ "args": { "contents": "% $0 %>" }, "command": "insert_snippet", "context": { "key": "selector", "match_all": true, "operand": "source.ruby", "operator": "equal" }, { "key": "preceding_text", "operator": "regex_match", "operand": ".*<", "match_all": true } ], "keys": "%" ] },

This should fix the issue with triggering the autocomplete on the same line as “<%”

0 Likes

#20

Unfortunately, it doesn’t fix it. But I’m using SublimeERB and that seems fine for now. Eventually I’d really like to find out how to close those tags with the snippets.

0 Likes