Sublime Forum

Bracket Style

#1

Happy sublime user here.

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

[code]if (operation) {

}[/code]
but I’d like:

[code]if (operation)
{

}[/code]

to fit in with the project style guide.

0 Likes

#2

Can you give a bit more information? Are you using a snippet to get that? If so, which one?

0 Likes

#3

I’m using the PHP snippets. The example would have been "if ".

0 Likes

#4

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 framework.zend.com/manual/en/cod … ndard.html

0 Likes

#5

Thought so, not what I wanted to hear.

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:

0 Likes

#6

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]// search
^((?: |\t))(^\s].?))\s*({)\s*$

//replace
\1\2\n\1\3
[/code]

0 Likes