Home Download Buy Blog Forum Support

Rule Completion and Niceties?

Rule Completion and Niceties?

Postby danielschwartz on Wed Mar 09, 2011 3:40 pm

Been using Sublime Text now for a bit and i've pretty much switched over completely from TextMate.

The only thing i'm missing (which im sure is a an option), is the what TextMate does while im coding up HTML/CSS. For instance TextMate automatically adds a semi-colon after a colon when working in a CSS file, and will automatically create the closing > in HTML files when im creating DOM nodes.

If anyone could point me in the right direction that would be fantastic.
danielschwartz
 
Posts: 4
Joined: Wed Mar 09, 2011 3:37 pm

Re: Rule Completion and Niceties?

Postby danielschwartz on Tue Mar 15, 2011 4:21 pm

really? nothing? this seems like such an essential and easy feature it's gotta be included.
danielschwartz
 
Posts: 4
Joined: Wed Mar 09, 2011 3:37 pm

Re: Rule Completion and Niceties?

Postby CyberWalrus on Wed Mar 16, 2011 10:37 pm

not really a solution, but I use breevy or textexpander to do this kind of thing.
for example, a rule

Abbreviation: :
Replacement: :%(cursor);

in either of those would type a semi-colon every time you typed a colon, and leave the cursor between them.
As I said, hardly a solution as they have to be activated manually when you are coding in CSS, but both pieces of software I mentioned are much more powerful than that, so I'm sure you can find much more uses for them
CyberWalrus
 
Posts: 4
Joined: Fri Mar 04, 2011 5:20 pm

Re: Rule Completion and Niceties?

Postby jps on Wed Mar 16, 2011 11:12 pm

You can do these sorts of things fairly easily with key bindings - that's how the bracket pairing is done, for instance. Take a look through the key bindings for some examples, but for the CSS example, I'd imagine you want something along the lines of:

Code: Select all
{ "keys": [":"], "command": "insert_snippet", "args": {"contents": ":$0;"}, "context":
   [
      { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
      { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
      { "key": "selector", "operator": "equal", "operand": "source.css", "match_all": true }
   ]
}
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: Rule Completion and Niceties?

Postby rchl on Thu Mar 17, 2011 12:14 am

That's very nice.

Selector can probably be improved a bit though, to not trigger when typing selectors like div:before for example.
This works for me:
"source.css -meta.selector.css"
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

Re: Rule Completion and Niceties?

Postby qqq on Thu Mar 17, 2011 8:48 am

That is useful, thanks! I like to be able to jump semicolon with Tab, so here's my modified code:

Code: Select all
{ "keys": [":"], "command": "insert_snippet", "args": {"contents": ": $1;$0"}, "context":
   [
      { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
      { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
      { "key": "selector", "operator": "equal", "operand": "source.css -meta.selector.css", "match_all": true }
   ]
}
ST2 Win7 64-bit
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am

Re: Rule Completion and Niceties?

Postby rchl on Thu Mar 17, 2011 10:56 am

You can instead use ctrl+enter to jump to next line.
rchl
 
Posts: 148
Joined: Fri Mar 04, 2011 11:02 pm

Re: Rule Completion and Niceties?

Postby qqq on Thu Mar 17, 2011 3:21 pm

good to know it. still i may want to add a comment on the same line
qqq
 
Posts: 57
Joined: Tue Mar 08, 2011 9:49 am


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], gotcha1 and 17 guests