Eclipse 中的自动 EOL 转换
需要在 Eclipse 工作区下的所有资源中保持 EOL 格式一致。
我知道 Eclipse 首选项为新创建的文件设置新的线条样式,但我希望对已经存在的文件进行自动转换。有一些设置/插件吗?
我只想设置一次并确保所有行结尾都采用相同的格式。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
除了窗口>;首选项>一般>您已经了解的新文件的工作空间设置,有一个文件>;将行分隔符转换为选项。我不知道任何现有的插件/工具会在您保存时自动执行此操作,但您当然可以编写一个或将转换行结束部分作为您的过程的一部分。
为了使您自己更轻松,您可以通过转到窗口>将键盘快捷键绑定到转换命令。首选项>一般>键并使用“分隔符”进行过滤:
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":
在 Eclipse 中,要转换现有文件的行结尾:
转到文件浏览器视图,然后单击要转换的项目/文件夹/文件。
从菜单栏中选择“文件”>“文件”。将行分隔符转换为 > Windows / Unix / MacOS 9。
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.
您可以使用
搜索
对话框搜索资源,然后转到文件搜索
选项卡。您可以在此处输入正则表达式。输入\r\n
或您要更改的任何行结尾。然后点击
替换..
按钮而不是搜索
。...好吧,我的回答没有考虑这一点。
You can Search your resources with the
Search
-Dialog and go to the tabFile 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 ofSearch
.... ok, my answer does not consider this.
您可能通过 Eclipse 保存操作获得有用的结果:如果 Eclipse 格式化程序也转换 EOL 样式,您可以使用它来修改您正在修改的文件的 EOL 样式。
不幸的是我这里没有 eclipse,所以我无法测试这是否真的有效。不过,值得一试。
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.