windows - PhpStorm 使用 Linux 行在 Windows 上保存

标签 windows phpstorm line-endings

环境:Windows + PhpStorm

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

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

最佳答案

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


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

enter image description here


要更改特定现有文件的行尾: 打开文件并通过状态栏中的适当部分更改它.. 或通过 File |文件属性 |行分隔符

enter image description here

enter image description here


附言

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

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

关于windows - PhpStorm 使用 Linux 行在 Windows 上保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40470895/

相关文章:

php - Docker 工具箱 Xdebug 无法与 PhpStorm 一起使用

.net - 在 Windows 服务启动时等待网络配置完成

windows - 浏览器中的 RDP 或 VNC

c# - 为 .NET 应用启用高性能 GPU

git - phpstorm 和 git 远程仓库

intellij-idea - 0xDBE/PHPStorm/IDEA 无法同步数据库表

Git commit 忽略行尾

git - 如何查看git存储库中已经存在的行尾类型?

windows - 如何使用 Jenkins 以 Unix 行结尾检查 Windows 中的 CVS 存储库?

python - 在 virtualenv 中设置环境变量(Python、Windows)