Home Download Buy Blog Forum Support

Bracket Style

Bracket Style

Postby Popcorn on Fri Jul 30, 2010 1:58 am

Happy sublime user here.

Just a minor niggle. Is it easy to change the the bracket style? It defaults to:

Code: Select all
if (operation) {

}

but I'd like:

Code: Select all
if (operation)
{

}


to fit in with the project style guide.
Popcorn
 
Posts: 6
Joined: Wed Sep 03, 2008 2:36 pm

Re: Bracket Style

Postby jps on Fri Jul 30, 2010 6:26 am

Can you give a bit more information? Are you using a snippet to get that? If so, which one?
jps
Site Admin
 
Posts: 3062
Joined: Wed Mar 19, 2008 12:33 pm

Re: Bracket Style

Postby Popcorn on Fri Jul 30, 2010 3:31 pm

I'm using the PHP snippets. The example would have been "if <tab>".
Popcorn
 
Posts: 6
Joined: Wed Sep 03, 2008 2:36 pm

Re: Bracket Style

Postby nvartolomei on Sat Jul 31, 2010 10:44 am

you just have to modify all your snippets in %appdata%\Sublime Text\Packages\PHP

but i don't recommend to do so for if, switch, for, ... statements, take a look at http://framework.zend.com/manual/en/cod ... ndard.html
nvartolomei
 
Posts: 5
Joined: Mon Nov 16, 2009 7:33 pm

Re: Bracket Style

Postby Popcorn on Sun Aug 01, 2010 1:51 am

you just have to modify all your snippets in %appdata%\Sublime Text\Packages\PHP

Thought so, not what I wanted to hear.

but i don't recommend to do so for if, switch, for, ... statements, take a look at http://framework.zend.com/manual/en/cod ... ndard.html

That's not a reason, different projects have different coding styles. To say I should use the Zend Framework standard without reason is stupid.

I'll be editing the files :cry:
Popcorn
 
Posts: 6
Joined: Wed Sep 03, 2008 2:36 pm

Re: Bracket Style

Postby guillermooo on Sun Aug 01, 2010 8:37 am

Just an idea:

Instead of modifying the actual snippets, you might write a short plugin that looks for braces and moves them one line down? The following regexp might not cover all cases, but it's a starting point:
Code: Select all
// search
^((?: |\t)*)([^\s].*?\))\s*(\{)\s*$

//replace
\1\2\n\1\3
guillermooo
 
Posts: 723
Joined: Thu Jul 23, 2009 9:06 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests