Convert existing file line endings?

I know there's an option for new files, but is there a way to convert line endings of an existing file in phpStorm ?



I'm interested too. Currently I use Notepad++ for this task.


Hehehe.. I'm using Notepad++ for that. I used to develop for years with Notepad++ - it's one awesome piece of software.


When you commit the project to Git it prompts you to convert the line endings.

There is a setting in FILE -> SETTINGS -> VERSION CONTROL -> VCSs -> GIT - > Convert Text Files -> "Convert to projects's line separators"


That's if you use the Git plugin inside phpStorm. I use a different tool.
It think it will be superb to have an option to convert current opened file to Windows/Mac/Unix line endings, just as you can change the format of current document at the bottom right.


As it seems, annoyingly there is no easy way at the moment to do this.
Dmitry Jemerov says here:

IntelliJ IDEA always normalizes line break characters to \n when a file is loaded into the editor and uses the correct line break character when saving the file. Because of that, displaying the line break characters would not add any useful information.

So it's not even possible to do a regex search within PhpStorm editor, to replace undesired line feeds.

I hope PhpStorm devs issue this as a task and provide a possibility soon.


And two years later....

Has there been any update on how to convert existing files' line endings from one OS style (i.e. Unix) to another (i.e. Windows)?   Would be really nice.  I hate having to go to a different editor or open up a shell to keep doing this


...not really. I came up with a workaround to ease my day and configured SwissFileKnife as an "External Tool" and mapped the convert command to right-click - popup menu. That's better than nothing...


It is there indeed; just select the root folder in the Project tree, and then change the line ending trough the "File" menu. The manual did say this; I cant see why I missed that.



And, if you want to change the current individual file, in the bottom right of the window you can find:



I'm on Windows using Intellij Ultimat 2017.2. The problem I have is that even after setting the root directory to LF, whenever I save a file it still gets CLRF as line endings.

This is a breaking issue since we have ESLint rules with demand LF endings.


Christopher, does it also happen with a plain text file you create in this directory?


Please sign in to leave a comment.