Sublime Forum

Creating New Files and a Rails Auto-Complete Question

#1

I’m loving Sublime 2 so far on OSX, and have a couple questions.

First, is there a way to create a new file in my project without going to file/new, then navigating to where I want it in my project via the save dialog? I’d love to just right click on a folder or something and add a new file.

Second, under TextMate’s Rails support I like how when I type a # in an erb file it automatically files in the #{} syntax and moves my cursor. Is there a way I could add that using the Python tools, or some other way?

Thanks!

0 Likes

#2

+1 for me too. I just now noticed that creating a new file was not very intuitive (at least on OS X) and that “#{}” code completion is really, really handy in Rails programming. :smile:

0 Likes

#3

Well, this is a general Ruby request and not specific to Rails. Also, adding a file via the sidebar is a fully generic request.

As far as the #{} request goes, it should be active whenever you are in a double-quoted string and you type #[TAB] correct? I think that is what you are asking for, since #{} is only valid within a double-quoted string. Although, it is also valid within a backtick (`) string for shell execution.

This should be possible with a simple binding that is scoped to Ruby files and within a string.

0 Likes

#4

Generally, the #{} should activate just by typing a # inside a double quotes, not with a #[TAB].

0 Likes

#5
<snippet>
    <content><![CDATA[#{${0:$SELECTION}}]]></content>
    <tabTrigger>#</tabTrigger>
    <scope>string.quoted.double.ruby</scope>
    <description>Wrap selection with ‘#{}’</description>
</snippet>

This snippet works, but is there a way to trigger it by just pressing # key?

0 Likes

#6

[quote=“sublimator”]Soz, tired, can’t assume you(and/or others) know what to do with that eh?

Slap it in your User -> Preferences key-bindings or wherever …[/quote]

Sure, thanx, this is ‘almost’ perfect! :smile:
Almost, b/c it took some time to realize that i need to start typing after i pressed # to do actual text insertion, or press any non-destructive key (like arrow) to make selection (in case there was some) to appear.
Thanx again!

0 Likes

#7

[quote=“sublimator”]Sounds like you have a conflict with another snippet containing ‘#’, probably the ‘#{tab}’

Remove that and it should work instantly.[/quote]

Yep, works perfect now!
There were 2 conflicts: mine one, and bundled ruby’s Add-’#-=-’-Marker.sublime-snippet

0 Likes