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.
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.
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.
This is extremely frustrating. I'm using IntelliJ 2020.1
IntelliJ IDEA 2020.1 (Ultimate Edition) Build #IU-201.6668.121, built on April 8, 2020
In the bottom right of the status bar shows a EOL UI line ending that doesn't match the file. Newly created files follow the line ending of LF as set in the Settings tab, but existing files don't get changed when I toggle between LF and CRLF.
For example, The package.json file says line endings are LF. I run "od -c package.json" for example, and see that they are with LF only.
od -c package.json 0000000 { \n . . . . other stuff omitted . . .
I change to CRLF and I see
od -c package.json 0000000 { \r \n . . . . other stuff omitted . . .
I then change back to LF and the UI takes a little while before it changes but after it does I run "od -c" and the lines have not changed to LF even though the UI says it has.
od -c package.json 0000000 { \r \n . . . . other stuff omitted . . .
For good measure, I run Save-All (Ctrl+S) and this has no effect.
I've never used this feature before so perhaps I'm not using it correctly, but this thread implies that it should work the way that I'm trying to use it.
PyCharm 2020.1.2 fixed my line endings to good effect! ... but only when I remembered to start the latest PyCharm from the JetBrains! I had at first absent-mindedly used an stale old shortcut to lat year's PyCharm!
(I am using CRLF endings on Linux, by the way, while meddling with very old files from the CP/M era.)
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:
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...
Yep, just found it:
http://www.jetbrains.com/phpstorm/webhelp/configuring-line-separators.html#d10309e443
Sure is nice to have it there :-)
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?
This is extremely frustrating. I'm using IntelliJ 2020.1
In the bottom right of the status bar shows a EOL UI line ending that doesn't match the file. Newly created files follow the line ending of LF as set in the Settings tab, but existing files don't get changed when I toggle between LF and CRLF.
For example, The package.json file says line endings are LF. I run "od -c package.json" for example, and see that they are with LF only.
I change to CRLF and I see
I then change back to LF and the UI takes a little while before it changes but after it does I run "od -c" and the lines have not changed to LF even though the UI says it has.
For good measure, I run Save-All (Ctrl+S) and this has no effect.
I've never used this feature before so perhaps I'm not using it correctly, but this thread implies that it should work the way that I'm trying to use it.
PatS2265, it's a bug in 2020.1: https://youtrack.jetbrains.com/issue/IDEA-237629
Going to be fixed in 2020.1.2 Preview in two weeks. Sorry for the inconvenience!
Eugene Morozov any idea why that link to IDEA-237629 is broken?
Guillaume, sorry, didn't notice the reporter set limited visibility to the issue. Fixed, you can check it now.
PyCharm 2020.1.2 fixed my line endings to good effect! ... but only when I remembered to start the latest PyCharm from the JetBrains! I had at first absent-mindedly used an stale old shortcut to lat year's PyCharm!
(I am using CRLF endings on Linux, by the way, while meddling with very old files from the CP/M era.)
Now it's moved to File -> File Properties -> Line separators