Jump to content

PSA: indent your code, DAMMIT.


Jessica

Recommended Posts

I just went through a 700 line tpl line by line adding indentation. It had none. Gee, I wonder why the previous developer couldn't find his bugs?  :'( :'(

It took me 45 minutes to figure out where the loop was that he was messing up. So yes, I'm grumpy today.

Link to comment
Share on other sites

I know there's probably more than one tool that can do it for me, but by the time I was a quarter done I decided it would take longer to install those tools. For next time though definitely.

Any decent IDE should come with this feature.  You can even customize how the format looks.

 

Anyway, that's one of my pet peeves....

Link to comment
Share on other sites

I'm using jEdit, we tried setting up Eclipse and Netbeans in the past and could not get either to work with connecting to the repositories. I personally don't like a huge IDE with a ton of features, I'm used to Textpad. I like syntax highlighting and auto indent -  meaning when I type if(){ it indents the next line. But I've never seen one that can take a non-indented file and fix it. I checked jEdit and can't find it, even as a plugin.

Link to comment
Share on other sites

I'm using jEdit, we tried setting up Eclipse and Netbeans in the past and could not get either to work with connecting to the repositories. I personally don't like a huge IDE with a ton of features, I'm used to Textpad. I like syntax highlighting and auto indent -  meaning when I type if(){ it indents the next line. But I've never seen one that can take a non-indented file and fix it. I checked jEdit and can't find it, even as a plugin.

 

In vim, just select the text and press "=" ;)

Link to comment
Share on other sites

I'm using jEdit, we tried setting up Eclipse and Netbeans in the past and could not get either to work with connecting to the repositories. I personally don't like a huge IDE with a ton of features, I'm used to Textpad. I like syntax highlighting and auto indent -  meaning when I type if(){ it indents the next line. But I've never seen one that can take a non-indented file and fix it. I checked jEdit and can't find it, even as a plugin.

 

In vim, just select the text and press "=" ;)

 

Yeaaaaah. There's a reason I'm the only person on my team using Windows. I just can't adapt to vim. *hangs head*

Link to comment
Share on other sites

I'm using jEdit, we tried setting up Eclipse and Netbeans in the past and could not get either to work with connecting to the repositories. I personally don't like a huge IDE with a ton of features, I'm used to Textpad. I like syntax highlighting and auto indent -  meaning when I type if(){ it indents the next line. But I've never seen one that can take a non-indented file and fix it. I checked jEdit and can't find it, even as a plugin.

 

In vim, just select the text and press "=" ;)

 

Yeaaaaah. There's a reason I'm the only person on my team using Windows. I just can't adapt to vim. *hangs head*

the problem when using vim and windows editor is the tab vs spaces :) if you forgot to edit the settings of your windows editor to 4 space it will be a night mare of vim user lol

Link to comment
Share on other sites

Here is what I look for in an editor:

 

- Auto Indent

- Auto Close: Brace, Bracket, Quote, Apostrophe, Parenthesis

 

Netbeans formats fairly well not 100% perfect I noticed though

 

Before formatting:

<?php
class C{
private $v1 = "";
public $superman = array();
protected $batman = 1234;
public function __construct($thing){
$this->thing = $thing;
$cat = "Dog";
echo $cat;
}
public function something(){
$longvariablecounter = 0;
for($i=0;$i<10;$i++){
echo "Hello";
$longvariablecounter++;
}
}
}


$frenchFry = "10";
$bans = "123";
$c = new C($frenchFry);
$c->something();
echo "<br />";
echo $bans;
?>

 

After formatting:

<?php
class C{
    private $v1       = "";
    public $superman = array();
    protected $batman = 1234;
    public function __construct($thing){
        $this->thing = $thing;
        $cat = "Dog";
        echo $cat;
    }
    public function something(){
        $longvariablecounter = 0;
        for($i                   = 0; $i < 10; $i++){
            echo "Hello";
            $longvariablecounter++;
        }
    }
}
$frenchFry = "10";
$bans      = "123";
$c         = new C($frenchFry);
$c->something();
echo "<br />";
echo $bans;
?>

 

As you can see the alignment on variables in the for loop, are strange, and the equal signs don't line up that well some variables such as ones with arrays.

 

But it does do everything else quite nice!

Link to comment
Share on other sites

Here is what I look for in an editor:

 

- Auto Indent

- Auto Close: Brace, Bracket, Quote, Apostrophe, Parenthesis

 

- A good editor permits back-tabbing, too.

- Auto closing is a nightmare if the editor doesn't allow you to 'insert' through it.  Nothing is worse than auto closing and you have to cursor through containing punctuation!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.