问题
Need to keep EOL format consistent in all resources under Eclipse workspace.
I know about Eclipse preference that sets new line style for newly created files, but I would like to have automatic conversion for already existing files. Is there some settings/plugins?
I want just setup once and be sure that all line endings are in the same format.
回答1:
In addition to the Window > Preferences > General > Workspace
setting for new files that you already know about, there is a File > Convert Line Delimiters To
option. I don't know of any existing plugin/tool that will do this automatically when you save, but you could certainly write one or make converting the line ending part of your process.
To make it easier on yourself, you can bind keyboard shortcuts to the conversion commands by going to Window > Preferences > General > Keys
and filtering using "delimiter":
回答2:
In Eclipse, to convert the line endings for existing files:
Go to the file browser view, and click on the project/folder/file that you wish to convert.
From the menu bar, select File > Convert Line Delimiters To > Windows / Unix / MacOS 9.
回答3:
You can Search your resources with the Search
-Dialog and go to the tab File Search
. There you can enter a Regular expression. Enter \r\n
or whatever line ending you want to change.
Then hit the Replace ..
Button instead of Search
.
I want just setup once and be sure that all line endings are in the same format.
... ok, my answer does not consider this.
回答4:
You might get usefull results with Eclipse save actions: If the eclipse formatter also converts the EOL style, you could use it to modify EOL style only for the files you are modifying.
Unfortunately I don't have eclipse here, so I can't test if this actually works. Worth a try, however.
来源:https://stackoverflow.com/questions/5003830/automatic-eol-conversion-in-eclipse