Home Download Buy Blog Forum Support

Creating New Files and a Rails Auto-Complete Question

Creating New Files and a Rails Auto-Complete Question

Postby fleeno on Mon Jan 31, 2011 5:05 pm

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!
fleeno
 
Posts: 3
Joined: Mon Jan 31, 2011 5:01 pm

Re: Creating New Files and a Rails Auto-Complete Question

Postby RNHurt on Tue Feb 01, 2011 12:01 am

+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. :)
RNHurt
 
Posts: 13
Joined: Sun Jan 30, 2011 12:31 pm

Re: Creating New Files and a Rails Auto-Complete Question

Postby willi297 on Mon Feb 07, 2011 10:02 pm

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.
Greg Williams
Atomic Embedded, USA
http://atomicembedded.com
willi297
 
Posts: 121
Joined: Wed Nov 18, 2009 8:29 pm
Location: Grand Rapids, MI, USA

Re: Creating New Files and a Rails Auto-Complete Question

Postby RNHurt on Thu Feb 10, 2011 6:31 pm

Generally, the #{} should activate just by typing a # inside a double quotes, not with a #[TAB].
RNHurt
 
Posts: 13
Joined: Sun Jan 30, 2011 12:31 pm

Re: Creating New Files and a Rails Auto-Complete Question

Postby que on Tue Feb 22, 2011 2:52 pm

Code: Select all
<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?
que
 
Posts: 18
Joined: Sat Jan 30, 2010 9:24 pm

Re: Creating New Files and a Rails Auto-Complete Question

Postby que on Tue Feb 22, 2011 4:10 pm

sublimator wrote: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 ...


Sure, thanx, this is 'almost' perfect! :)
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!
que
 
Posts: 18
Joined: Sat Jan 30, 2010 9:24 pm

Re: Creating New Files and a Rails Auto-Complete Question

Postby que on Tue Feb 22, 2011 4:19 pm

sublimator wrote:Sounds like you have a conflict with another snippet containing '#', probably the '#{tab}' <tabTrigger>

Remove that and it should work instantly.

Yep, works perfect now!
There were 2 conflicts: mine one, and bundled ruby's Add-'#-=-'-Marker.sublime-snippet
que
 
Posts: 18
Joined: Sat Jan 30, 2010 9:24 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 24 guests