1 Replies Last post: Oct 30, 2013 10:35 PM by Mark Vedder  
Andrei Deftu Newbie 13 posts since
Jun 27, 2013
Currently Being Moderated

Oct 30, 2013 9:17 PM

Keep line separators when editing files.

Hi,

I am working on a multi-platform project which stores its source files with LF endings. Each time I open one file under Windows, the endings are set to CRLF, which is not what I want. I want to maintain whatever line ending the file has.

I set the option Code style - General - Line separator (for new files) to "Unix and OS X (\n)", but this is just a fix for new files.

How can I keep the line separators when editing existing files? Or at least, how can I specify what line separator to use for existing files? All the information I got on the net was only about git and "autocrlf = true" option which I don't care about.

Thanks.

Mark Vedder Apprentice 973 posts since
Dec 10, 2003
Currently Being Moderated
Oct 30, 2013 10:36 PM in response to: Andrei Deftu
Re: Keep line separators when editing files.

IDEA will keep the line ending type currently used in a file. So if you open a Unix (\n) file, it will keep it a Unix file. A Windows file (\r\n) a Windows file. The one exception is if you open a file that has mixed line endings, it converts the file to (as far as I can tell) to what ever is the most prominent occurring line ending. In a tie, I think it uses whatever you have set for the line ending for new files.

 

You can change a file's line endings via the icon on the right side of the bottom status bar:

 

line-ending-icon-in-status-bar.png

 

There may be a plug-in in the plug-in repository for adjusting line endings in project files. If not good old unix2dos or dos2unix tool could be used.

More Like This

  • Retrieving data ...