Eclipse: how to set file encoding based on file extension

Problem

I have an eclipse project that is designed to manage source code.

The project looks something like this:

MyProject
    .classpath
    .project
    src/
        com/myCompany/code
            DoStuff.java
            DoOtherStuff.java
            someText.foo
    conf
        someOtherTextFile.foo

As you can see, we have foo file extension files. The foo files use a different file encoding (ISO-8859-1), and then the rest of the files in my project. I want to configure eclipse to use ISO-8859-1 every time I open these files.

Here are the options I have found so far:

Solution 1 - tag each file one at a time

Right Click File -> Properties -> Text file encoding -> Other: ISO-8859-1

Then the line is added .settings/org.eclipse.core.resources.prefs:

encoding//conf/someOtherTextFile.foo=ISO-8859-1

This solution works fine, but I need to do this for every foo file in my project and I need to make sure that no one ever forgets to do this by adding a new foo file .

2 -

:

" Eclipse" "General > Content Types".

, ""

" " "" "*.foo". 'ISO-8859-1' " ".

"", .

( greg-449 , ).

, Eclipse ( ).

, , .foo, ISO-8859-1. , , .

, ?

+4
1

Greg-449 , :

Windows → → → → → → *.foo → ok → *.foo 'ISO-8859-1' → update → ok

Settings

Content Types

File linking

File encoding

-1

Source: https://habr.com/ru/post/1615316/


All Articles