Automate source formatting for specific folders in Eclipse - eclipse

In Eclipse you can format the whole source tree. You can format the whole project by right clicking it -> Source -> Format. You can do the same for sub-folders. I want to be able to do this automated for a specific set of sub-folders in my project, is there a way?

You can have the formatter run automatically on saving files, but the formatting is only applied to the edited files then (not a specific folder).
However, I do not see any good reason to not format all sources of a project the same way, which is why I hope you can take that as solution. :)

Related

Can i format full project in eclipse

Is it possible to format a whole project containing different files (like .java , .js, .jsp files) at once in eclipse.
If any one know please tell me it will save my most time.
thanks in advance
Select the project the Source -> Format

sorting files by date in project explorer in eclipse juno

Is it possible to show files in package explorer in the order of date they were created? I am using eclipse juno and I couldn't find any customize option in view menu of the project..
Currently the package explorer shows items in alphabetic order which cause me to search through the files to find the last modified project or java file. Can someone help?
I'd comment if I could to ask for clarification but don't have enough points...
I assume you don't have a team repository or you would have enabled its label decorations, which I know is available in svn. Label decorations will show the team metadata associated with the files. It won't have them sorted but with a small set, you can scan them manually.
In order for this to be useful with a large set, the sort would have to be across all folders/packages. You could open up file explorer(assuming windows os), to the project folder, perform a search with filter of 'datemodified:'. Now you may have to remove the semi-colon and add it again, hit enter. That would sort the folders by date, then the files by date..across all folders.
Its ugly but it works (as far as I understand the question). Good luck.

What files in Eclipse contains code templates and keyboard bindings?

I have three common workplaces where I use the Eclipse IDE.
A nice trick when using multiple common workplaces is to copy certain configuration files to Dropbox, and link to them in the original configuration location. This way, all settings and changes are instantly available in your other workplaces.
You've got your workspace with a whopping 100 megabytes of files. You've got your .eclipse which is closing in on 200 megabytes.
I would like to know which specific files contain my custom javascript code templates, and which contains my keyboard shortcuts, so I can share these, and only these, with myself through Dropbox.
Ideally, I'd like a list of of certain settings and their locations so I can choose to share more. But I haven't found something like this on Google.
Why am I not just sharing my entire workspace and configuration directory? Well, first, it is crazy big. Second, Eclipse is modular. In some places I use certain modules that I don't use elsewhere. And you all know that modules/plugins are a crazy mess of files and configuration from which there is no escape.
You can try to export Eclipse preferences from one workspace and export them to other workspace. If it doesn't work for your, enter a bug against corresponding Eclipse project.
I figured it out.
You can copy your ~/workspace/eclipse/.metadata to somewhere. Change a preference, and sync your workspace to your backup in order to find out what files are changed.
You'll find that a lot of settings are in ~/workspace/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/. The javascript templates and other javascript options are in ~/workspace/eclipse/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.wst.jsdt.ui.prefs
org.eclipse.wst.jsdt.ui.prefs = Code Templates
org.eclipse.jdt.ui.prefs = Syntax Coloring
org.eclipse.ui.editors.prefs = Text Editors

Opening many files in Eclipse with a script for formatting

So i want to format a bunch of files that i have to a certain standard. The problem is, there is A LOT of files. Is there anyway to have Eclipse open a file, hit CTRL+SHIFT+F (to format the file), save it, close it, then open the next file and repeat that process through a directory that i specify?
I don't have any experience with scripting so i have not even attempted doing something like this. I looked into plugins for Eclipse that could maybe do this but i really didn't get anywhere.
Any help is appreciated.
Thanks
You can right-click on any source folder in the Package Explorer (including the root of the project) and select Source > Format, or Source > Cleanup (which gives you even more control than a simple format)
You can right click on a folder in the Navigator or Package Explorer view and select Source -> Format. This will format all the files in the selected directory.

How do I save a file using the Eclipse compare editor

I can't seem to find a way to save the changes I make to project files using the two-way compare of two local project file folders. I can step through the differences and copy changes from left to right, but there's no way, as far as I can tell, to save those changes. I looked at the files outside of Eclipse after I copy changes left to right and they are not being updated.
Here's a help site explaining what I'm doing http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Freference%2Fref-25.htm it sayz 'You can save changes to resources that are made in the comparison editor.' but doesn't say how...
I can just copy and paste the contents of the merged file into a new editor window but this seems like a silly way to go about this. I guess I could also create a diff patch and apply it to my project as well...
It seems that using *nix command diff is a piece of cake:
diff -rupN original/ new/ > original.patch
as stated in the "The Ten Minute Guide to diff and patch"