Home Download Buy Blog Forum Support

Auto-indentation problem

Auto-indentation problem

Postby Swift-R on Mon May 24, 2010 8:40 pm

With sublime default settings it works fine:

Code: Select all
Indented code:

    if($this == $that) {
        echo 1;
    }


When I open the {, it automatically closes and sends the pointer to the middle of the braces.
But I like to have "autoMatchEnabled false" and when I try the same code, right after I write echo 1; I hit ENTER, the cursor goes to the right place (below "if"), then I close the brace "}" and it goes to the start of the line instead of keeping below the "if", like this:

Code: Select all
Indented code:

    if($this == $that) {
        echo 1;
}


Is there a fix?
Thanks.
Swift-R
 
Posts: 2
Joined: Mon May 24, 2010 8:30 pm

Re: Auto-indentation problem

Postby edanm on Mon May 24, 2010 9:01 pm

I just tested it, and for me, after entering "echo 1;" and then "enter", the cursor doesn't go below the if, it goes below the "echo".
Then, hitting the "}" key places the brace below the if.
The algorithm seems to be that inserting the "}" will automatically indent it one tab stop left of wherever the cursor is now.

Are you sure you're not "manually" hitting backspace after entering the "echo 1;" line?


By the way, out of curiosity, why do you turn off autoMatchEnabled? I find it amazingly helpful.
At the worst, it doesn't get in your way since entering the extra brace will override the first.
At best, after hitting the first brace and getting the second one automatically, hitting enter will (like magic) position the second brace in the appropriate place, and the cursor in between them.
After an hour of getting used to this, I now find it really awesome.
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: Auto-indentation problem

Postby Swift-R on Thu May 27, 2010 2:51 pm

I guess I have explained it wrong. When you hit ENTER, the cursor goes to the right place (below echo and not if), but then I have to do a backspace so I can close the brace below the if, when I click the brace key, it unindents one more tab. It should work fine if I don't use the backspace to keep the cursor below the if but this is wrong.

Thanks.

By the way, I am starting to like auto match... :D
Swift-R
 
Posts: 2
Joined: Mon May 24, 2010 8:30 pm

Re: Auto-indentation problem

Postby edanm on Thu May 27, 2010 3:41 pm

By the way, I am starting to like auto match...

Glad to hear it! :)

I think the behavior right now is that a brace key automatically unindents by tab-size, so you're supposed to not hit backspace before inserting the closing brace.

That said, a new beta just came out which Jon says has big changes to autoindenting, and I haven't had a chance to look at it yet, so it hopefully solve this issue.
edanm
 
Posts: 131
Joined: Thu Mar 04, 2010 11:05 pm

Re: Auto-indentation problem

Postby jps on Thu May 27, 2010 4:06 pm

This should no longer be an issue in 20100527: if you press backspace after pressing enter, that'll be taken as a signal for manual indentation control, and the brace won't be automatically unindented.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 32 guests