Reputation: 28056
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.
Upvotes: 4
Views: 438
Reputation: 1323165
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)
^[\t]*? [\t ]*?\S.*?$
alt text http://img825.imageshack.us/img825/390/eclipsecsspace.png
Use the following module:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "configuration_1_3.dtd">
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: t
Description: none
-->
<module name="Checker">
<property name="severity" value="warning"/>
<module name="TreeWalker">
<module name="Regexp">
<property name="format" value="^[\t]*? [\t ]*?\S.*?$"/>
<property name="message" value="spaces are used instead of tab for indent"/>
<property name="illegalPattern" value="true"/>
</module>
</module>
</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)
Upvotes: 2
Reputation: 42879
In the preferences dialog: General -> Editors -> Text Editors : Show whitespace characters.
(This works in Eclipse 3.5 at least).
Upvotes: 2