how can I make the internal editor the default editor in eclipse - eclipse

I want the default edior to be the internal editor and not the system editor.
I have it configured in window->preferences->file associations to use default internal xml editor for *.xml yet eclipse always tries to open files with OS system editor. How can I prevent this?

The editor type is mapped to file type; you can do this on a per-workspace (global) or per-project basis.
It should be pretty much as simple as this:
http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.wst.xmleditor.doc.user%2Ftopics%2Ftxprefs.html
Go into "Help, Install Software, What is already installed?" and make sure you have "Eclipse XML Editors and Tools" installed. You you don't, then get it.
Finally, create a new, "clean" project, add an XML file, and verify it works correctly

I found this question but the answers didn't help me, so I continued searching and found the answer here http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-51.xhtml
Basically, in the Preferences, General > Editors > File Associations, then define your file types (if not already there), and select an editor.

Right Click on File from Project,
Select Open with ....
Select your editor

Related

Eclipse Indigo "Save Actions" are not being applied

I'm new to Eclipse and downloaded the following version:
Eclipse Java EE IDE for Web Developers.
Version: Indigo Release
Build id: 20110615-0604
[edit] Eclipse Platform Version 3.7
I have edited Java > Editor > Save Actions to do the following: Remove trailing white spaces on all lines, Correct indentation
When I save the .java file, those actions are not applied... is this a bug?
Found this that might be related: https://bugs.eclipse.org/bugs/show_bug.cgi?id=350475
Assuming that this relates to JavaScript files, then the related Eclipse bug could be helpful.
The problem (as I've just experienced) is that you can edit the JavaScript -> Save Actions preferences via the context menu when editing a JavaScript file, but the actions will not be run.
The solution is to right click on the project containing the .js file, and select Configure -> Convert to JavaScript project.
The bad news is that this will then will also enable Eclipse's not-so-great JavaScript validation, therefore telling you that libraries such as moment.min.js are broken.
Well for those of you who have found this topic... I did find 2 solutions, no thanks to Eclipse, other than the fact that it is open source and people can write plugins.
Eclipse Platform Version 3.7
AnyEdit - plugin that does it for you when you Save file (I believe this is what eclipse SHOULD be doing)
Go to: Window > Preferences. Then under General > Keys. Make sure drop down for Scheme: is Default and enter 'remove trailing' in the filter. You should then see "Remove Trailing Whitespace" under the command column. Bind it to your own key command.
The only drawback to #2 is that you have to actually press the key binding while editing the file, kindof like a cleanup action.
Too bad Eclipse hasn't taken the approach that ALL file types should be configurable in this way... sometimes I miss TextPad.
Old question, but at least for newer Eclipse versions there's a better solution: Go to the project properties, then to Project Facets. If it tells you that your project isn't in faceted form yet, then convert it. Afterwards (or if it already was faceted), just enable the JavaScript checkbox.
I had the same issue with Eclipse 4.4 (Luna) and this fixed it for me, the save actions are now executed on save.
Adding to jlh's answer, I also had to configure the JavaScript include path of the project to enable save actions. Before that even a manual "Clean Up ..." from the source menu wouldn't work.

Highlight .tpl syntax in Eclipse

I've been googling and can't find a solution for this. I'm trying to setup .tpl files to use either HTML syntax highlighting or PHP syntax highlighting. Has anyone does this, or do you know how?
Thanks
Go to Window -> Preferences-
Then General -> Editors -> File Associations-
Add the PHP Editor to the *.tpl file type. You may have to create the *.tpl type if it doesn't already exist.
You may also have to set the content type for your tpl files in Content Types also under the General settings. Scroll down to PHP Source File and make sure *.tpl exists there as well.
Then you need to restart eclipse to make it work.
Go to Window -> Preferences -> General -> Content Types
Select Text -> CSS, click Add, write *.tpl and save.
Do the step two for Text -> HTML, Javascript and PHP.
I took that from this link. You can get that form there or I give their content below if the anyhow that link doesn't work. It works for me nicely.
steps how to install SmartyPDT 0.9.1
Be sure that the .TPL files are not associated with any content type (file type). In Eclipse,
Be sure that the .TPL files are not associated with any content type (file type). In Eclipse,
Go to Help-> Install New Software
At the Work With section click on the Add... button. Give the new "Site" a name and set the location with http://smartypdt.googlecode.com/svn/trunk/org.eclipse.php.smarty.updatesite/ , then click OK. Go back to the Install New Software window and select the newly added "site". If the "Group items by category" check-box is checked, uncheck it. Now you should be able to see 1 item in the software list named "Smarty Feature"
Select the Smarty Feature, click Next> and from here afterwards it shouldn't be a problem.
If you are prompted that this is an unsigned package, just ignore the warning and install it anyway.
After the installation completes, restart Eclipse and it should be working.
Define a default PHP executable of type 'Zend Debugger' (only if you install vanilla Eclipse PDT):
In Eclipse go to Window->Preferences->PHP->PHP Executables Click on the Add button. Enter a name for that executable definition, for example "PHP localhost", complete the 2 fields which ask you for the PHP executable path (the PHP binary CLI executable) and php.ini path. Be sure that the PHP debugger is the Zend Debugger.
Installing smarty on eclipse kepler fails
(see Install SmartyPDT 0.0.9.1 in Eclipse Kepler).
The recommendation there is to use the PHP Development Tools (PDT) from former eclipse juno version. But in contrary to the recommendation I did not DELETE the mentioned features folder but I just uninstalled the plugins from eclipse itself (Help/About/InstallationDetails):
Uninstall all PDT packages
Restart eclipse
Then follow the instructions in above answer to install the PDT packages from Juno version and then the smarty package.
All these Installations worked without error.
But unfortunatly the *.tpl files are still not syntax highlighted. What to do more?
Our *.tpl file extension is not associated with the HTML editor in Eclipse by default.
Open Eclipse’s preferences.
Expand General from the tree on the left and select Content Types.
Expand Text on the right and select HTML. Click the Add... button below, enter *.tpl and click the OK button.
General -> Editors -> File Associations
Click Add..., enter *.tpl, and click OK.
Select HTML Editor from the Associated editors: section below and click the Default button to the right.

Eclipse autocomplete not working in some Java files

I have noticed that autocomplete is not working in some of java files in Eclipse.
Also, the files where autocomplete is not working, display a hollow "J" as the icon for the Java file. The files where autocomplete is working, icon for java file is a filled "J"
I am wondering if someone can point out what went wrong all of suddent, why the change in icons and why autocomplete and syntax highlighting is turned-off in the files with a hollow "J" icon?
Thanks.
update
Basically, I was doing what VonC has suggested but Eclipse was not refreshing that it why I was thinking that VonC's suggestion isn't working, after doing a refresh, the problem resolved.
Since this question is highly ranked on Google, I will add a solution to fix general auto complete issue, not for 'hollow J' ones.
Try Window (Windows/Linux) or Eclipse (OS X) -> Preferences -> Java -> Editor -> Content Assist -> Restore Defaults
also
Content Assist -> Advanced -> Restore Defaults
some answers (restore defaults) above do not work for some adt bundle installs as of jan '13.
in those cases, go to
Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced
and tick on the JAVA PROPOSAL options.
In this following picture, MyClass.java has a hollow J, because it is explicitly excluded from the sources to build:
Could you go to the properties of the project, "Java Build Path" Section, "Source" tab and see if some exclusion filter has been set ?
It is usual for instance to define:
**/Test*.java
to exclude at first building any unit-test class (when you have a large set of sources and do not want to be presented with Test classes during auto-completion, or do not want them considered during source searches).
Those with a hollow J aren't part of the build path of the project, so they can't participate in the normal build process and therefore auto-complete won't be enabled for these files (and other Java editor features!). You must add the folders with the Java files to be built to the build path using the 'source path' section of the project properties. This can be accessed by right clicking on a project in the project navigator / package explorer and going to Properties. See http://www.informit.com/articles/article.aspx?p=367962 for details.
Additionally, if the files aren't part of a Java project in the first place, you must create a project and move the files in, or put the files in an existing one. Again, make sure these file are under a source directory as described by that section of the project properties.
(source: teradata.com)
I cope with the issue by deleting the file if autocomplete does not work. Just before copying the source code. Then I have recreated the java file with the same name. Pasted the source code previously copied.
As an addendum to the #VonC answer, make sure that the Java files are part of the Inclusion pattern. I had a case where a build process was creating the project while only including .js files and not the Java files:
You can manually edit the inclusions via the Edit button. In my case, a fix was made to the build script to make it permanent.
Neither Restoring Defaults or my build path (file was already in package directory w/other files where auto-complete was working) fixed problem. Fix for me was to close the file explicitly (right click on file name in tab) and re-open. Interestingly, just re-starting Eclipse didn't work either.
Make sure you have the right directory structure. I believe that:
Hollow J icon beside Java file - will not be build
Normal J icon beside Java file - is a file to be build.
I made a mistake when I created webapp artefact. By default it does not create folder for Java, but for resources. I mistakenly put my sources there.
Have a look - see the difference.
I was able to get this fixed in Visual Studio Code, VSCode but entering crtl-shift-p and typing in clean. When I did that I ran the "Java: Clean Java Language Sever Workspace" command. This fixed my autocomplete issue for me.

Eclipse 3.3 default editor under Vista

I switched some months ago from Eclipse 3.0 under Win2000 to Eclipse 3.3.2 under Vista.
With my old platform, when I opened a file from eclipse navigator, for which no particular editor was configured, the file was defaultly opened with LPAD editor.
Now with my new platform, in the same situation, Eclipse delegates the choice to Vista, so to keep the same behavior I have to explicitly add the "unknown" extension in Window / Preferences, menu General / Editors / File Associations, and configure it to open with eclipse text editor.
Of course ".*" si not accepted like a valid extension, so I have to do it extension by extension.
And by the way there are tons of such "unknown" extensions I work with : .launch, .cvsignore, .pmd, .ruleset, .bindings, .csv (I want to edit such with textEditor, not excel), .vm, and so on...
From eclipse navigator I can open the context menu and select, for THIS particular file, to open it with the text editor, but it does not apply to other files with the same extension.
It's worse when opening the file from Open Resource dialog box, as in this case the context menu is not even available.
In a word, is there any way to configure eclipse 3.3.2 under Vista so that any file with an unknown extension will open with a given eclipse default editor ?
You do have (since eclipse3.2):
Open With->System Editor from the context menu
alt text http://www.myeclipseide.com/modules/ContentExpress/img_repository/docs/55M1/snaps_crossover.gif
That will pick the editor the system (here Vista) currently associates with your files.
But that still leaves you with the unpleasant task to set up the proper associations within the System itself (Vista)
There are some relevant feature requests for similar use cases (but they are there for years so don't expect to implement them soon):
Default editor for unknown extensions
File Associations doesn't accept standard wildcards
Currently you have to manage each important "dot-started names" individually in File Associations as you mentioned, I suppose.

Eclipse CDT Invalid Project Path

I have a C project that is built using a makefile, Eclipse constantly warns about "Invalid project path: Duplicate path entries", but I cannot figure out what the hell it wants me to do. I would like to disable this warning and continue with my life.
My application compiles and runs fine, with not a single warning except this one. Being a conscientious developer I am keen to fix this problem so I have the warm fuzzies only a clean build can bring.
This worked for me with Eclipse 3.7.2 and CDT 8.0.2:
Open the project properties | C/C++ Build | Discovery Options.
Click the button by Clear discovered entries now:.
Rebuild.
It is seems to be a new feature in CDT 8. I have had this "Invalid project path: Duplicate path entries" problem for years, and this is apparently the newly provided solution.
Before doing this there were duplicate paths under C/C++ General | Paths and Symbols | Includes tab. I could not get rid of these. They only appear when Show built-in values is checked, so they are apparently generated somehow. After doing the above they were replaced with a set that did not have duplicates. The only difference is that the same settings appeared under Assembly, GNU C, and GNU C++. Previously they were different sets. The ones for Assembly were empty, for example.
So far the problem has not returned.
This problem is a real pain to deal with. It doesn't work very well.
This is applicable to Eclipse 3.4.1 / CDT 5.0.1
From what I can tell, when you create a "C/C++ Project" within CDT, it will try to auto-detect your include paths. Great idea, but the implementation is horrid.
If you delete or rename a directory, the old directory is leftover. If you rename the project, the old directory is leftover. When Eclipse can't find that old directory, it gives you that warning.
My solution is turning the automated discovery off entirely and managing my include paths manually. You need this list of include paths for things like ctrl-click (auto-navigate to defines/functions/files/etc) and shading out #define blocks. It builds the index off this list.
Here's what you need to do:
Right click on your project in the project explorer and go to properties.
Go to C/C++ Build -> Discovery Options
Uncheck "Automate discovery of paths and symbols"
Now go to C/C++ General -> Paths and Symbols
You'll see under the Includes tab Assembly, C and C++ languages with corresponding auto-discovered include directories.
Go to all 3 languages and delete everything.
Open your makefile and transcribe your includes into the corresponding language.
A project rename will still cause the indexer to break. ${project_name} and other globals do not seem to work. If you're having trouble, use the "Workspace" button to browse to the directory you want to include, as that seems to always work but entering it manually does NOT.
Hit apply, then OK.
Right click your project, go to index->rebuild
Restart eclipse.
This should fix things forever. Any time something improperly is shaded out due to a #define or #ifdef block, it's because that list of files is outdated. You'll also know that list is outdated if you get "unresolved inclusions" on #include lines.
Doug Schaefer, hopefully Google indexes this, you find your name, and you fix this awful implementation. =)
I found this bug report to help my problem. I had moved some include paths and couldn't get rid of the old paths.
I've seen this problem too, old paths
are never deleted. To manually fix the
file you need to move/delete the
${projectname}.sc file found under
${workspace}/.metadata/.plugins/org.eclipse.cdt.make.core
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206372
Using Eclipse Luna and CDT 8.5
I fixed the issue by
Open the project properties | C/C++ General | Paths and Symbols
Look at the Source Location tab, I had renamed a directory and it was not updated in this list.
Rebuild
Here I just found another way to re-detect the path automatically:
Open "Workspace Settings-> C/C++ -> Build -> Settings -> Discovery"
Find "CDT Build-in Compiler Settings [Shard]"
Click "Clear Entries" and "Reset" button on the right
Rebuild projects and Done
Hope this will help.
Reference:
http://qing.blog.sina.com.cn/1802712302/6b7334ee33004def.html
It seems like a bug in CDT.
If you really want to get rid of it, you should try getting rid of the spaces in the project path; this was suggested in a search result for the error. If that doesn't work, you can try to open the .cproject file -it's where all the CDT settings lie- and check for an actual path with duplicate entries.
You should check if you have manually defined a symbol that eclipse can figure out from your makefile. I have a project that has a manually written makefile and the problem was solved by removing symbols that I had manually added to C/C++ General -> Paths and Symbols -> Symbols.
No needs to remove .metadata guys, just delete all path located in C/C++ General -> Paths and Symbols -> Symbols and replace them on using click buttom but don't give the path manually
Here's a late answer for Eclipse 4.4 (which does not have a Discovery option).
Delete the project's infoPath file. Eclipse or the ADT plugin (not sure which) will recreate it, and populate it with the correct paths.
You can find the project's infoPath file at <Eclipse workspace>/.metadata/.plugins/com.android.ide.eclipse.ndk/<project>.pathInfo.
I think Eclipse or the ADT plugin determines the new paths from two places: (1) the NDK directory set under Eclipse preferences, and (2) paths in Application.mk. All those paths become "Built-in" paths under Eclipse.
Also see How to change built-in C/C++ paths pointing to a deleted android-ndk-r9 installation?