简体   繁体   中英

How to make eclipse recognize the correct file extension/open the correct editor for files opened outside of the scope of a project?

I have a simple file index.jsp outside of a project in a location such as /home/user/other/ and I open it in eclipse with File - Open file . The file opens but things such as content assist are not working.

I tried creating a file inside an eclipse project (with File - new - jsp file ) and everything works (including content assist).

Is there a way to force eclipse to open the proper editor for files opened outside the scope of a project?

Edit: I'm running eclipse indigo for java ee.

There seems to be a problem with the file not being in a project. I tried moving the file inside a project and now it works. I still want to know how to make this work outside a project though.

Are the file associations set correctly in your eclipse version?

This can be done under Preferences -> General -> Editors -> File Associations

You can set the desired editors for each file extension there. You can also set multiple editors for file associations. In that case you should set the default associated editor to the desired one.

When the default editor is set to your desired one, it should open files from outside of your project with this one.

For JSP files specifically, Java content assist will not work outside the workspace since it relies on a project's Java Build Path (you'll find the same limitations opening .java files). This is normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM