Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make the Home key put me at position 1 in Eclipse?

I'm using Eclipse Galileo, with a plugin for PHP development. I use the same editor at work and at home for my personal projects (at work, I do not use PHP or the PHP plugin, however).

One thing about using it is driving me crazy, though, and though I've spent a couple of hours digging through all the different options under Window->Preferences (as well as searching around the Internet), I can't find out how to do this one thing. Maybe someone here can help me?

Here's what's happening. I've got a line of code:

<?php
    echo "Hello world";  // <-- I'm talking about this line
?>

and my cursor is on the 'w' in 'world'.

I hit the 'Home' key on my keyboard. In my key mappings, it claims this is supposed to take me to the beginning of the line ('Line Start', to be exact). To me, 'start' means 'there is nothing to the left of this position', aka position 1. As in, no tabs, no spaces, no nothing, and if I hit the 'Left arrow' key on my keyboard, I should then move to the end of the previous line. You know, how your browser works inside of a textarea, and how Word, Notepad, Excel, and almost every other program works.

Instead, when I hit 'Home', my cursor moves to position 5, the very beginning of the word 'echo'. This, in case it's not clear, is NOT the start of the line. It's the start of the non-whitespace content on the line, but that's not the way I expect this key to function. If I hit 'Home' again, I get to the REAL start of the line - position 1. Hit it again, and I'm back to 5.

It's possible that it's not a matter of the 'Home' key at all, but potentially a side-effect of the 'Smart Indenting' function. I also can't figure out how to turn that off (I've seen a few posts here that indicate that it can't be done), and it frequently messes up my formatting which causes me to waste my time fixing it, as I'm particular about how my code looks when I'm coding. For example, when I copy/paste a line, the indenting gets all messed up (the pasted line tabs in to where Eclipse thinks it should be, in spite of all of the preceding whitespace I've copied along with the text on the line). This may be related to the operation of the 'Home' key, or to Eclipse's conception of what the 'start' of the line really means.

I realize that people out there who don't code like I do will have an initial reaction of 'change the way you type', or 'ignore the messed-up formatting and let Eclipse auto-fix it later' or something similar. That's possible, but will take quite a bit of time, and is actively hindered by the fact that I'd be changing the way I work on this one app (in this one setting, as it doesn't do this at work), while all the others will continue to operate as I expect them to. So for me, that sort of suggestion is not a very viable option.

Thanks in advance for any help, advice or assistance you can offer.

PS. If you know of a way for me to keep 'Auto-indenting' on but turn off 'Smart Indenting', please let me know that too.

like image 244
Kyle Humfeld Avatar asked Feb 03 '23 23:02

Kyle Humfeld


1 Answers

Untick General > Editors > Text Editors > Smart caret positioning at line start and end. Note that this will apply to all Eclipse editors, not just the PHP editor.

like image 105
AndiDog Avatar answered Feb 06 '23 15:02

AndiDog