Sublime Forum

Please help me keep Sublime Text 2!

#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

#21

Hmmm, what exactly is happening when you use the latest snippet? I’m wonder because it seems to work fine on my computer.

0 Likes

#22

I get the same issue, where it will close the tag if I type an equal sign inside <%

If I do something like:

:method =>

as soon as I hit the ‘=’ it will put a %> next to it.

0 Likes

#23

Just remove all the keybindings that I gave you except for the last one. It should work then.

Let me know if there is still a conflict. The lastest binding doesn’t trigger on ‘=’. Hope that helps.

0 Likes

#24

I did, and still just using the last one you gave me produces the same error above :frowning:

0 Likes

#25

Thanks for this, I am using it now and like it except for one thing: when you have the cursor next to a parentheses it will be highlighted all the time. Now, I know I’m getting really picky here, but is there a way to make it behave like in Textmate where it highlights the matching pairs and then fades out?

That would be really nice.

0 Likes