PhpStorm 保存在 Windows 上的 Linux 行结束

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40470895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:42:44  来源:igfitidea点击:

PhpStorm saving with Linux line ending on Windows

windowsphpstormline-endings

提问by Jurosh

Environment: Windows + PhpStorm

环境:Windows + PhpStorm

Issue: PhpStorm saves file with Windows line endings - and for shell script it's issue so there is need to always convert after copying to server.

问题:PhpStorm 使用 Windows 行结尾保存文件 - 对于 shell 脚本,这是问题,因此在复制到服务器后需要始终进行转换。

Question: Is possible to configure PhpStormto save file with Linux line endings- \nand not \n\r(new line + carriage return)?

问题:是否可以将PhpStorm配置为使用Linux 行结尾保存文件-\n而不是\n\r(换行 + 回车)?

回答by LazyOne

You can safely use \nline ending for .phpand most of other files as well -- PHP on Windows will read such files just fine.

您也可以安全地\n.php大多数其他文件使用行结尾——Windows 上的 PHP 可以很好地读取此类文件。



To set default line endingfor all newfiles: go to Settings/Preferences | Editor | Code Styleand change Line separator (for new files)option to the desired style (e.g. Unix and OS X (\n)).

为所有文件设置默认行尾:转到Settings/Preferences | Editor | Code Style并将Line separator (for new files)选项更改为所需的样式(例如Unix and OS X (\n))。

enter image description here

在此处输入图片说明



To change line ending for a particular existing file:open the file and either change it via appropriate section in Status Bar .. or via File | Line Separators

要更改特定现有文件的行尾:打开文件并通过状态栏中的相应部分更改它 .. 或通过File | Line Separators

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明



P.S.

聚苯乙烯

If you do have EditorConfig plugininstalled and enabled ... you might also configure this via .editorconfig file-- there you may specify what line ending to use (this can be done on per file extension level .. so it's more flexible than PhpStorm's own setting).

如果您确实安装并启用了EditorConfig 插件……您也可以通过.editorconfig 文件配置它——在那里您可以指定要使用的行结尾(这可以在每个文件扩展级别上完成……所以它比 PhpStorm 的更灵活自己的设置)。

This will also work in another editor/IDE that supports such file.

这也适用于支持此类文件的另一个编辑器/IDE。