如何让 Home 键将我置于 Eclipse 中的位置 1?

2022-01-16 00:00:00 eclipse-plugin eclipse

我正在使用带有 PHP 开发插件的 Eclipse Galileo.我在工作中和在家中为我的个人项目使用相同的编辑器(但在工作中,我不使用 PHP 或 PHP 插件).

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).

不过,使用它的一件事让我发疯了,虽然我花了几个小时研究 Window->Preferences 下的所有不同选项(以及在 Internet 上搜索),但我不能了解如何做这件事.也许这里有人可以帮助我?

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
?>

我的光标在世界"中的w"上.

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

我按了键盘上的主页"键.在我的键映射中,它声称这应该将我带到行的开头(确切地说是行开始").对我来说,开始"的意思是这个位置的左边没有任何东西",也就是位置 1.就像没有制表符、没有空格、什么都没有,如果我按下键盘上的左箭头"键,我然后应该移动到上一行的末尾.您知道,您的浏览器如何在文本区域内工作,以及 Word、记事本、Excel 和几乎所有其他程序如何工作.

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.

相反,当我点击Home"时,我的光标移动到位置 5,即单词echo"的开头.如果不清楚,这不是该行的开始.这是行中非空白内容的开始,但这不是我期望此键起作用的方式.如果我再次点击Home",我会到达该行的真正开始 - 位置 1.再次点击它,我会回到 5.

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.

这可能根本不是Home"键的问题,而是智能缩进"功能的潜在副作用.我也不知道如何关闭它(我在这里看到一些帖子表明它无法完成),它经常弄乱我的格式,导致我浪费时间修复它,因为我特别关注我的代码在编码时的外观.例如,当我复制/粘贴一行时,缩进变得一团糟(粘贴的行标签到 Eclipse 认为它应该在的位置,尽管我已经复制了所有前面的空格以及行上的文本).这可能与Home"键的操作有关,或者与 Eclipse 对行的开始"真正含义的概念有关.

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.

我意识到那些不像我那样编码的人会有改变你输入的方式"或忽略混乱的格式并让 Eclipse 稍后自动修复它"之类的初始反应相似的.这是可能的,但需要相当多的时间,并且由于我将改变我在这个应用程序上的工作方式(在这个设置中,因为它不会在工作中这样做)这一事实而受到积极阻碍,而所有其他人将继续按照我的预期运作.所以对我来说,这种建议不是一个非常可行的选择.

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.如果您知道我可以打开自动缩进"但关闭智能缩进"的方法,也请告诉我.

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.

推荐答案

取消勾选 General > Editors > Text Editors > Smart caret 在行首和行尾定位.请注意,这将适用于所有 Eclipse 编辑器,而不仅仅是 PHP 编辑器.

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.

相关文章