Reputation: 10049
I am using netbeans and this is driving me a bit nuts.
This is my code:
if($pos !== false)
{
// Explode()
$the_type = explode("(", $type);
}
I want it to indent the stuff inbetween the braces like so:
if($pos !== false)
{
// Explode() it to get to just the type
$the_type = explode("(", $type);
}
Can someone please tell me where do I change this setting and with what values?
I have been in tools->options->editor but dont know what exactly to change and with what values.
Thanks!
Upvotes: 0
Views: 434
Reputation: 168843
I've just had a go at configuring Netbeans to do what you want, and I haven't managed it. Having trawled through the Netbeans config trying to make it work, I suspect that the answer is, sadly, that what you're wanting to do is not possible in Netbeans.
Sorry about that.
It might be worth posting it as a feature request for a future version.
Code indentation style is a personal thing, and has no effect on the quality of the code itself, so please read the rest of this answer without any sense that I'm trying to push you away from your preferred style.
If your code is going to be kept private and not use any third-party libraries then your coding style is entirely yours, and there really isn't any reason to be swayed by any other opinion. However, if you're planning to make your code open source, or you need to work with third party libraries, then it's worth looking at what others are doing.
Firstly, it might be worthwhile reading the Wikipedia article about code indentation styles.
The interesting thing about this article from your perspective is that the style you want to use isn't mentioned at all. Virtually every other combination of brace position and indentation is named and discussed, but not yours. I've also never seen your style in use anywhere else. What I read into that is that your style is pretty unusual.
Another thing worth mentioning are the recently-published PSR coding standards for PHP. Obviously, there's no compulsion to use these standards, but they have been standardised by a very large number of open source PHP projects, including all the major frameworks.
The PSR standards define a coding style that is very different from yours. And most of the popular open source PHP projects are moving to it. There's even a code tidier utility that formats code to meet the PSR standards. (I was going to suggest it as direct solution to your problem, as I thought it might be able to fix the code to how you wanted it, but it seems that it only does PSR standards)
So there's some food for thought. As I say though, I don't want to sway you from your personal preferences. Unfortunately, if you want to stick with Netbeans, it seems that might force your hand more than anything I could say.
Upvotes: 2