How to tell Eclipse to stop moving my curly brace backwards

Go To StackoverFlow.com

1

I recently installed Eclipse (Helios Release) PDT and am trying to set the preferences to my project's style of code formatting.

I have gone into...

Eclipse PDT > Window > Preferences > PHP > Editor > Typing

...and unchecked all options.

I have also gone to:

Eclipse PDT > Window > Preferences > PHP > Editor > Templates

...and edited the 'Function Statement' template to look like this:

function ${function_name}() 
    {
    ${cursor};
    }

..and edited the 'class statement' template to look like this

class ${class_name}
    {
    function ${function_name}() 
            {
            ${cursor};
            }
    }

Now, back in the PHP editor, I am trying to write a method in the format like:

protected function testMethod()
    {
    return 'Hello'; 
    }   

In order to do this. First I write:

protected function testMethod()

Then, I hit return and the cursor lands under the 'p' or protected. Which is OK I spose:

protected function testMethod()
|

Then, I hit TAB and the cursor moves forward to where I'd like my opening curly brace to be (as expected):

protected function testMethod()
    |

-- The problem: --

Then, as soon as I type my curly brace, Eclipse moves it backwards to end up under the 'p':

protected function testMethod()
{

So, each time I type an opening curly brace I have to go back and move it forward again to where I wanted it:

protected function testMethod()
    {

Then I carry on.

Which part of Eclipse is responsible for this behaviour and how can I stop Eclipse from moving the curly brace backwards?

Any help would be appreciated.


Updates in response to suggestions:

I have gone into...

Eclipse PDT > Window > Preferences > PHP > Editor

and unchecked both:

  • Smart caret positioning at line start and end

    and

  • Smart caret positioning in PHP names

Thanks for the suggestion Victor Nitu, but it did not fix the issue.

2012-04-04 05:16
by JW.


2

I don't recall the UI & prefs back in the Helios, but as I can see in Indigo, I have the following setting:

PHP -> Editor: Smart caret positioning at line end (chackbox)

Let me know if it works.

LE: Confirmed as not working in Indigo either. I'll be back if I find something.

2012-04-04 05:48
by Victor Nițu
Thanks. I have that setting in Helios and have turned it off too. it did not seem to stop the probs. I'll update the question - JW. 2012-04-04 05:49
I am browsing the user setting in Eclipse right now, still no answer, and I begin to suspect this is due to an Eclipse bug or misfeature. Going to try some internal files soon, if any - Victor Nițu 2012-04-04 06:00
I also suspect this is a Java editor feature, which has broken during the PDT porting. Other Java programmers complain about it too: https://bugs.eclipse.org/bugs/show_bug.cgi?id=10968 - Victor Nițu 2012-04-04 06:03
Ahaa!. Thanks for that. A quick skim of this bug comment makes me guess the fix is something to do with AbstractTextEditor.Navigation.SmartHomeEnd=true. I will have a play with it later today - JW. 2012-04-04 06:48
I searched my Ecplipse programme directory for 'AbstractTextEditor.Navigation.SmartHomeEnd' or 'SmartHomeEnd' and nothing found. Oh well -its not a config option I can alter myself w/o knowing a bit more about java - JW. 2012-04-05 02:59
I grepped the eclipse dirs multiple times, all I found were some Java binaries... until no - Victor Nițu 2012-04-05 22:12
Ads