Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable diff in line separators in IntelliJ IDEA?

I'm using Intellij IDEA 14 on Windows and Git as VCS on Unix server. The line separator in Windows is CLRF (\r\n) and LF (\n) in Unix. In Git, I'm using config --global core.autocrlf input. This will translate all CRLF's to LF's upon commit.

When I'm using "Reformat code" option on well-formatted file, IDEA marks files as changed and shows diff in line separators only.

Right mouse button on changed file -> Git -> Compare with Latest Repository Version

How can I disable that in IDEA?

like image 656
avfrolov Avatar asked Nov 14 '14 09:11

avfrolov


People also ask

How do I show diff in IntelliJ?

To open the Diff & Merge page, open settings by pressing Ctrl+Alt+S and navigate to Tools | Diff & Merge. Click this button to scroll both differences panes simultaneously. If this button is released, each of the panes can be scrolled independently.

What is Crlf line separators?

CR and LF are control characters or bytecode that can be used to mark a line break in a text file. CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line.

What are line separators?

The line separator used by the in-memory representation of file contents is always the newline character. When a file is being loaded, the line separator used in the file on disk is stored in a per-buffer property, and all line-endings are converted to newline characters for the in-memory representation.

Should be on a new line IntelliJ?

There are shortcuts for this in IntelliJ IDEA! Simply hit Shift+Enter to start a new line below the current line or Ctrl+Alt+Enter (⌥⌘Enter on Mac) to start a new line above the current line.


2 Answers

In the bottom right of your window, change [CRLF] to [LF]

like image 189
Peter Lawrey Avatar answered Sep 22 '22 16:09

Peter Lawrey


I'm also developing on windows and Because our servers are powered by Linux and all the code has to base on Linux I have preferred to change all my files to LF instead of CRLF.

from git command line:

git config --global core.autocrlf false 

i'm working with intellij idea so it's quite easy:

1) File --> settings --> editor --> code style: (for any new file will be created)

a. Scheme : default

b. Line separator: unix and os x (\n)

2) mark the root of the project --> file --> line separator --> LF unix and os x (\n) (for exist files)

Remark: you can also use apps like dos2unix.exe or some other scripts.

than I did using my command line: (you can do this also from the idea)

git commit -m "bla bla" git add . git push origin master 

since then, I didn't got those warnings

like image 21
dsaydon Avatar answered Sep 22 '22 16:09

dsaydon