In any company where coding standard is followed, it’s really necessary to configure your IDE. Most of the Java developer use Eclipse as an IDE and hardly know about configuring their Eclipse editor before start writing code. It is recommended to use spaces instead of tab because different editor show different number of space for tab and code appears different on different editor. If white space is used instead of tab then code appears similar on all editors. Sometime its really hard to spot tab in the code without any visual aid. Eclipse has really a cool feature to show whitespace characters. It uses “¶” for new line, “.” for space where as “»” is being used to display tabs. You can configure editor by going to window > preferences > general > Editors > Text Editors then select “show line number”, “show whitespace characters”, and “Insert spaces for tabs” and click “OK”. You will see whitspaces as shown below.
You can also configure eclipse to place spaces instead of tab. You can do this by
Selecting project from left pane > “ALT + Enter” > Java Code Style > Formatter > You will see the following window.
Click “configure workspace” this will lead to the following window. This window allows you to manage different coding format for different project. As shown below you can either create a new profile or edit the existing one.
For editing click edit button. This will pop-up another window as shown below. Here you need to select tab policy as “space only” and configure indentation and tab size according to your wish.
You can also explore and edit other configuration(e.g Braces, white space, Blank lines etc.) based on your requirement. Once formatting is defined hit OK to apply the changes. This may not change the existing code formatting but can be changed by pressing “CTRL+A” then press “CTRL+I”. This will format your file in click of your finger. This also comes handy where reformatting is required for poorly formatted file.
If you are looking for vim configuration then checkout this post.
Hope this blog helped you in some way. If you like this blog then please share it. You can also leave your comment below. You can find Facebook page here.