So, we are integrating another project in our code base. It does not follow our formatting rules. I have auto-formatting upon save configured. So, I could go to each file and save it again but is there a way to script Eclipse so that it applies formatting rules to every single file in my workspace?
Right click on the project(s) (can multi-select) and choose Source -> Format in the menu.
Try Source -> Clean up..., Use custom profile -> Configure.... it has more powerful options there.
Make sure you are in Package Explorer, then right-click and select the Source menu. Some of the other views (e.g., Navigator) won't show this option.
Related
When i try to use the code autocomplete of intellij by using ctrl+space it dosen't work.
What i need to do?
example:
In this code i want to use the add method of List and it dosen't give me the option to.
Several possible reasons:
Your file doesn't reside in a content root and is not bound to a build path, so it doesn't get the required class definitions and resources needed for code completion. To fix, right click your root source directory -> Mark Directory As -> Sources Root.
Check to see if you accidentally turned on the Power Save mode (File | Power Save Mode). Turning it on minimizes power consumption of your laptop by eliminating the background operations, including error highlighting, on-the-fly inspections, and code completion. Turn it off.
Make sure the JDK for your project is set up correctly in the File | Project Structure window.
A file containing classes and methods that you want to appear in completion suggestions list is marked as a plain text file. To fix, right-click on the file -> Mark as Java class.
External libraries that contain methods that you want to appear in the completion suggestions list are not added as dependencies or global libraries.
I have java code style formatter of Eclipse (for that matter it can be formatter of the other language also). When I import he format then it is saved in the workspace and that is applicable for that workspace.
I want code format/style imported and saved in the Eclipse setting itself so that this Eclipse used by anyone gets the format whatever workspace they use.
Is it possible to override the default format? Do I have to write my own plugin?
Thanks,
I can suggest the following in the Java perspective, Eclipse version Indigo...
click Window -> Preferences
expand Java -> Code Style
click Formatter
This will get you to the Formatter screen below. Follow the link on the top right
and see if this provides you with what you are requesting.
Configure Project Specific Settings screen
I wanted settings to be present in the eclipse packaging itself so that these settings (code format, template, spacing strategy etc.) are not repeated at every project and workspace level.
I got a way (at least it works on Linux with neon version). Here are the steps
Open eclipse with some workspace location
Apply all the settings like code formatting, template, Editor
preferences and all other preferred settings present in Window ->
Preferences Press OK. it will save the preferences.
Go to File -> Export -> General -> Preferences and press Next
Make sure Export all is checked and then provide the To
Preference File location and then Click Finish
Now open the exported file in you favorite editor
You will observe it is like a properties file with each property prefixed with /instance/ or /configuration/ (these are preference scopes). Remove all these prefixes (after that all the properties will look like org.* or net.* etc.). You will also see some workspace path related properties are present in this file, either remove them or change to appropriate one.
Save this file with some name say my-eclipse-preference.epf and copy
this file to your eclipse location (where eclipse start file is
present, say ECLIPSE_HOME)
Open $ECLIPSE_HOME/configuration/config.ini and add a line with
the property puluginCoustomization=my-eclipse-preference.epf at the end and save config.ini.
Restart the eclipse, you will find your settings are present even if you open with empty/new workspace. If you are starting from terminal then got to
the ECLIPSE_HOME directory first and then start.
If you want to start from the terminal but you want to avoid going
to the directory to start (i.e. starting from any location) then you should store the file my-eclipse-preference.epf at some standard location and have the value of puluginCoustomization with full path in config.ini.
Hope this helps.
I'm trying to have a standard code style for my project, and I have found http://editorconfig.org/, that is a standard for that. I like it very much, and Intellij supports it (we use Intellij).
But I have read a lot and I haven´t found how I can export all my code styles of Intellij to a .editorconfig file. I only can export them to an XML that is only for Intellij.
Or is there any webpage where I can read ALL the editorconfig domain specific properties for Java? In the editorconfig github wiki they only have a few.
Go to "File->Settings (Preferences in OS X)->Editor->Code Style". At the bottom of the right pane there is a section for Editor Config options, which now includes an "Export" button. This will only export formatting options that are available in the Editor Config specification.
To include advanced options from IDEA you will have to save IntelliJ specific files with the project.
If you want to do this without saving the entire ".idea" folder and "*.iml" files, you can also export the IDEA configuration to an xml file and save in a place where everyone can get to it.
In "File->Settings->Editor->Code Style". At the top of the right pane, there will be a "Scheme" field with an dropdown of options.
Next to the dropdown is a cog/gear image that will expand to give
some options depending on which scheme you have selected.
The two options you need are the "Export..." option and the "Import Scheme"
options which do what their names imply.
With later Intellijs (I'm using 2020.1), the configuration export is available via Settings -> Editor -> Code Style and then the gear icon. See the screenshot below, and the selected menu options:
In newer versions #Pytrys solution does not work anymore. Now you have to do it with File -> New -> EditorConfig file:
Don't think IntelliJ will do this for you.
You'll probably have to Export IntelliJ's Code Styles as a "Code Style XML File" and then manually parse that to your EditorConfig file. Or find a parser on the internet.
To export all your Code Styles from IntelliJ:
Hit "Ctrl + Alt + S".
Editor > Code Style.
Click the "Manage" button next to where IntelliJ states your Scheme.
Export > Export as Code Style XML File.
HTH
Is there any way to skip some Java files when compiling under Eclipse?
Remove the class from the build path. You can do this for a single file or group of files by selecting them in the Project Explorer, then right click → Build Path → Exclude.
You can always exclude the item from being built. Right click on the file and go to build-path. Then click exclude.
Delete (or move) them. It can't compile what isn't there ;)
Note: Other forms of removing the content you don't want compiled also work.
This page should help you. If you wish to remove a file from compilation you can delete it, as cdeszaq suggested, or you can change the extension of it(For example if you have test.txt changing it to test.txtz would pretty much make it un-openable)
There's another way to do it. I discovered it by first using the Build Path -> Exclude option in other answers, as Eclipse said something about configuring filters.
Right click the project -> click Properties -> click Java Build Path -> click Source tab -> select ProjectName/src -> click Edit... (or double click Excluded) -> add an Exclusion pattern like com/blah/blah/blah/, potentially with wildcards.
It looks like the wildcards are your standard * and ?, but they also have **, which appears to be for wildcarding any number of folders, which must imply that * and ? are for only wildcarding a single file/folder name.
We use Eclipse with projects in CVS. It has proven to be the simplest to create a new workspace when having to deal with another branch or application, and then use Team -> Import project set to get all the needed projects from CVS.
Unfortunately, I then have to do the following each and every time:
Change text font to Consolas 11 pt
Disable spell checking in text editors
Run everything in the background
plus some more of the same.
I'd like to change the standard values once and for all in the Eclipse distribution files after having unzipped the distribution (Windows). Where are these defaults located inside Eclipse?
EDIT: For now we just have a preference file which must be read in. An extra step, but works...
EDIT 2014: I've ended up creating a workspace with the settings I want, and then creating a new copy everytime I need a new one. Also handles Maven Central information etc. Accepted the oldest answer saying essentially this.
You can export your settings from a workspace and import them into any other (this basically does what VonC's answer says, but with some measure of error checking).
To do so, in the source workspace select File->Export...->General->Preferences, then select Export All and enter a file to export to, then Finish.
You can then import the preferences into any workspace by doing File->Import...->General->Preferences, browse to the preferences file and hitting Finish.
I have created a clean workspace with all settings i want to have. This workspace i have copied into a save folder i will never delete ;)
When i want to create a workspace for a new project, i copy the confugured workspace and thats it.
I have than configured the svn repository path, code format (you also can import preferences in eclipse for this), view configuration and so on.
Try checking:
<workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings
Some .prefs files could be interesting to copy from one workspace to the next.
(like org.eclipse.team.cvs.ui.prefs which contains any non-default value for CVS settings)
I want to fix the defaults inside Eclipse so the workspace is created with the defaults I want every time.
Hard core solution:
Change the .options file within <eclipse-SDK-3.5-win32>\eclipse\plugins\org.eclipse.team.cvs.core_3.3.200.I20090430-0408.jar (that is the name I have for eclipse3.5)
That is the file with the default values, at least for CVS.
Here's what I do:
Start up Eclipse
Without importing or starting any projects, edit the workspace and make all the config changes you want
Open up the workspace in windows explorer and create a copy of the folder.
Then, any time you wish to use it, copy this folder to your new workspace folder location - you may need to create the new workspace folder first (and definitely call it something different.)
This is what I do anyway. Yes, it's very dirty but it does get what I want pretty quickly!
When importing preferences (Rich Seller's approach above), especially those that were created by someone else, make sure you backup your Eclipse environment first. That's easy, since it's portable - just copy it to a temporary location.
I've totally hosed my Eclipse environment importing preferences in the past, and importing my own preferences, which I exported just prior to importing, did not fix my issues.
Fix the defaults inside Eclipse so the workspace is created with the defaults, If you want every time suggestions, then
Go to eclipse extract path -eclipse\configuration\.settings -> Edit -org.eclipse.ui.ide ->
Change value to true: SHOW_WORKSPACE_SELECTION_DIALOG=true
Similarly in this file you can directly change other default settings.
I find a way to do that:
open <eclipse>\plugins\org.eclipse.cpp.package.cpp_1.4.2.201210131-1456\plugin_customization.ini
and add
folding
org.eclipse.cdt.ui/editor_folding_enabled=true
org.eclipse.cdt.ui/editor_folding_preprocessor_enabled=true
then new project will enable folding by default.
So
You need to know where your prefer locate, in my case, folding is under org.eclipse.cdt.ui, you can try on an project then check <workspace>\.metadata\.plugins\org.eclipse.core.runtime\.settings to find it
"org.eclipse.cpp.package.cpp_1.4.2.201210131-1456" should be variable depends on what version you use. whatever it's, you should find "plugin_customization.ini "