Reputation: 3394
I want to format the JSON files in my eclipse on save file action, based on number of spaces that i can configure. I tried using JSON Editor Plugin but it gave me null pointer exception on saving.
Then i tried JSON Tools plugin and it worked but it used a tab for formatting the lines.
Is there any hack that i can do with plugin jar to configure and change TAB to 4 spaces?
Are better json formatter available for eclipse?
Upvotes: 11
Views: 37720
Reputation: 6667
To change any file to open in default editor Goto Eclipse Menu Window -> General -> Editors -> File Associations
You will see lots of File Types section available, Select the file in File Types Section, In Associated editors section you will find most available editors to open the file.
Select Any editor and click on Default button to open file in default editor window.
Upvotes: 0
Reputation: 84
As of Eclipse 4.6 (Neon) a JSON Editor is included in the Eclipse IDE for Java EE Developers.
Upvotes: 2
Reputation: 1807
Some other extensions adhere to the preference set for the general text editor.
If it doesn't clash with other settings you can try:
General -> Appearance -> Editors -> Text Editors
[x] Insert spaces for tabs
Upvotes: 5
Reputation: 160
Have you tried Json Tools for Eclipse? It is handy and lightweight Eclipse plugin. I have checked this right now and it works as you want - if there are TABs in a modified JSON file, they are changed to 4 spaces.
You can find it in Marketplace or install it using update site:
https://bitbucket.org/denmiroch/jsontools/src/default/JsonSite/
Upvotes: 9