{"id":63,"date":"2013-06-15T01:05:35","date_gmt":"2013-06-15T01:05:35","guid":{"rendered":"https:\/\/code4reference.com\/?p=63"},"modified":"2023-10-01T13:35:20","modified_gmt":"2023-10-01T13:35:20","slug":"code4referenceeclipse-editor-and-formatter-configuration-code4reference","status":"publish","type":"post","link":"https:\/\/code4reference.com\/?p=63","title":{"rendered":"Eclipse editor and formatter configuration"},"content":{"rendered":"<p>In any company where coding standard is followed, it\u2019s 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 <b>\u201c\u00b6\u201d<\/b> for new line, <b>\u201c.\u201d<\/b> for space where as <b>\u201c\u00bb\u201d<\/b> is being used to display tabs. You can configure editor by going to window &gt; preferences &gt; general &gt; Editors &gt; Text Editors then select \u201cshow line number\u201d, \u201cshow whitespace characters\u201d, and \u201cInsert spaces for tabs\u201d and click \u201cOK\u201d. You will see whitspaces as shown below.<\/p>\n<p><a href=\"http:\/\/code4reference.com\/wp-content\/uploads\/2013\/05\/Java-JMeter-src-java-com-code4reference-jmeter-threads-HostThreadGroup.java-Eclipse-Platform-_004.png\"><img alt='java-jmeter-src-java-com-code4reference-jmeter-threads-hostthreadgroup-java-eclipse-platform-_004-8221459' src='https:\/\/code4reference.com\/wp-content\/uploads\/2013\/06\/Java-JMeter-src-java-com-code4reference-jmeter-threads-HostThreadGroup.java-Eclipse-Platform-_004-8221459.png' \/><\/a><\/p>\n<p>Eclipse white space characters after enabling the configuration<\/p>\n<p>You can also configure eclipse to place spaces instead of tab. You can do this by Selecting project from left pane &gt; \u201cALT + Enter\u201d &gt; Java Code Style &gt; Formatter &gt; You will see the following window.<\/p>\n<p><a href=\"http:\/\/code4reference.com\/wp-content\/uploads\/2013\/05\/Properties-for-JMeter-_007.png\"><img alt='properties-for-jmeter-_007-e1370054446342-3828591' src='https:\/\/code4reference.com\/wp-content\/uploads\/2013\/06\/Properties-for-JMeter-_007-e1370054446342-3828591.png' \/><\/a><\/p>\n<p>Eclipse formatter<\/p>\n<p>Click \u201cconfigure workspace\u201d 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. <a href=\"http:\/\/code4reference.com\/wp-content\/uploads\/2013\/05\/Preferences-Filtered-_009.png\"><img alt='preferences-filtered-_009-e1370054595937-2846251' src='https:\/\/code4reference.com\/wp-content\/uploads\/2013\/06\/Preferences-Filtered-_009-e1370054595937-2846251.png' \/><\/a><\/p>\n<p>Eclipse Preferences (Filtered)<\/p>\n<p>For editing click edit button. This will pop-up another window as shown below. Here you need to select tab policy as \u201cspace only\u201d and configure indentation and tab size according to your wish. <a href=\"http:\/\/code4reference.com\/wp-content\/uploads\/2013\/05\/Profile-Eclipse-built-in-_011-e1370054365123.png\"><img alt='profile-eclipse-built-in-_011-e1370054660347-2257495' src='https:\/\/code4reference.com\/wp-content\/uploads\/2013\/06\/Profile-Eclipse-built-in-_011-e1370054660347-2257495.png' \/><\/a><\/p>\n<p>Eclipse Profile editor<\/p>\n<p>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 \u201cCTRL+A\u201d then press \u201cCTRL+I\u201d. This will format your file in click of your finger. This also comes handy where reformatting is required for poorly formatted file.<\/p>\n<p>If you are looking for vim configuration then checkout <a href=\"http:\/\/code4reference.com\/2013\/06\/configure-vim-to-put-spaces-in-place-of-tab\/\">this post<\/a>.<\/p>\n<p>Hope this blog helped you in some way. If you like this blog then please share it. You can also leave your comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In any company where coding standard is followed, it\u2019s 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=63"}],"version-history":[{"count":1,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":358,"href":"https:\/\/code4reference.com\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions\/358"}],"wp:attachment":[{"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/code4reference.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}