How can I disable adding '^M' character at the end of each line ?

PhpStorm add DOS/Windows line-ending characters. I'm tired of using dos2unix command to remove it.
Settings > Code style > Line Separator (for new files)  - doesn't work!

How can I disable adding '^M' character at the end of each line ?

10 comments

Hi Andrey,

Settings > Code style > Line Separator (for new files)  - doesn't work!

Works just fine here for new files (in both v5 and v6 EAP) on Windows 7.

When editing existing file the IDE will preserve line endings (it detects it based on first few lines -- if file is completely empty it should use default one).

If you are using v5 -- try Webmaster plugin -- it can detect and convert between different line endings (plugin is not compatible with current EAP builds of v6).


P.S.
How do you create new file -- "New | PHP file/class" or just "New | File" ? Try both and see if there will be any difference. If there will be -- I have some idea which possibly may help.

0

Uh, I'm sorry. I have a problem with existing file not new... Is there any solution for files already in project ?

0

What version do you use (Help | About)?

0

Use already mentioned Webmaster plugin (Settings | Plugins)-- it can convert between line endings for existing files (or whole folders) as well as capable of notifying you if opened file has different line endings to the default settings.

http://plugins.jetbrains.com/plugin/?webide&pluginId=6983

Actual ticket (possibly will be implemented in v7 .. or 8): http://youtrack.jetbrains.com/issue/IDEA-77929

0

Bazzik wrote:

Use already mentioned Webmaster plugin

Nice plugin. What about to convert edit lines not whole file ?

0

All IDEs on IDEA platform do not keep/remember individual line endings (in case you have them mixed in the same file) -- the one detected from first few lines should be used when saving the file. While editing the file, IDE treats all line endings as "\n".

0

Hello,

I have the similar, but not quite the same problem.

We have a project with a long-term history (and, thus, CVS history), and in the one file there exist lines with different code endings: part of file is ended with \n, some lines with \n\r.

But when I change such file, IDEA automatically changes the WHOLE file so that to unify line endings according to default settings (they may be different). In any case, big parts of file are changed.

As a result, with each commit we break `git blame' history because of huge changes.

Is there to disable this functionality AT ALL (i.e. line endings formatting)?

 

Thanks in advance.

Ilya

0

Hi @Iliyapalachev

As far as I know -- no.

  • When IDE open the file .. it reads and detects the general line ending (first few lines).
  • During editing all line endings are stored as \n
  • When IDE saves the file -- it replaces \n by actual line ending detected on step #1

https://youtrack.jetbrains.com/issue/IDEA-83481#comment=27-313345 -- this dev comment (and above and below) describes the same (the way how it works).

As far as I know with such approach there would be no way of implementing of what you requesting here.

 

P.S. Please note that those conversations took place before IDE have introduced "display line ending"  and "convert line ending" functionality (including this ticket -- it was created before that -- just proper dates got lost when moved to new forum engine).

But in any case -- preserving line ending in a file with mixed line endings does not seem to be possible.

Partially related: https://youtrack.jetbrains.com/issue/IDEA-83777

0

Please sign in to leave a comment.