在 Eclipse 的文本编辑器中,制表符是否可能看起来与空格不同
是否可以将选项卡设置为具有不同的背景颜色(例如略为灰色)或在 Eclipse 文本编辑器中放置一个小符号(如“↦”)?如果它是特定于语言的,我使用 PHP。
我们公司的编码标准是用于缩进的制表符,但源代码中经常有空格,因此很高兴看到这些空格在哪里,以便我在处理那段代码时可以更正它们。我不想运行脚本来全局修复它们,因为这会破坏我们版本控制中的合并,并且如果开发人员复制并粘贴了一些示例代码或其他内容,它们可能会在开发人员意识到的情况下回来。
如果它能够突出显示行首的空格或带有红色背景或其他内容的制表符后的空格,那就太好了。我可以通过对“^|\t +”进行正则表达式搜索来模拟这一点,但这也会突出显示选项卡本身,而且我希望它能够永久突出显示,即使当我使用搜索其他内容时也是如此。
Is it possible to set tabs to have a different background color (e.g. slightly grey) or put a little symbol (like "↦") in Eclipse text editors? If it's language specific, I'm using PHP.
Our company coding standard is Tabs for indenting, but often there are spaces in the source code, so it would be great to see where these spaces are so that I can correct them when working on that bit of the code. I don't want to run a script to just fix them globally because that would break merging in our version control, and they may come back without the developer realising if they copy and paste some sample code or something.
What would be really nice is if it could highlight spaces at the beginning of lines or spaces after tabs with a red background or something. I can sort-of simulate this by doing a regex search for "^|\t +", but that also highlights the tab itself, and I'd like this to be permanently highlighted, even when I am using the search for other things.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在首选项对话框中:常规 ->编辑->文本编辑器:显示空白字符。
(这至少适用于 Eclipse 3.5)。
In the preferences dialog: General -> Editors -> Text Editors : Show whitespace characters.
(This works in Eclipse 3.5 at least).
为此,您需要一个外部插件。
以下使用 Checkstyle(适用于 Java)进行说明。
但是您可以使用 phpcheckstyle (相同想法,但您需要修补该开放源以添加正则表达式检测,请参阅论坛获取补丁示例)
alt text http://img825.imageshack.us /img825/390/eclipsecsspace.png
使用以下模块:
注意
configuration_1_3.dtd
:如果您无法访问最初编写在模块 xml 文件中的 dtd( http://www.puppycrawl.com/dtds/configuration_1_2.dtd:参见< a href="http://checkstyle.sourceforge.net/config.html#XML%20Details" rel="nofollow noreferrer">模块 XML 配置)You need an external plugin for that.
The following uses Checkstyle (for Java) for illustration.
But you can use phpcheckstyle (same idea, but you need to patch that oppen source to add the regex detection. See the forum for patch examples)
alt text http://img825.imageshack.us/img825/390/eclipsecsspace.png
Use the following module:
Note the
configuration_1_3.dtd
: you need one dtd if you can't access the one originally written in the module xml file (http://www.puppycrawl.com/dtds/configuration_1_2.dtd: see Module XML configuration)