DiogoSL

DiogoSL

How to achieve same formatting on Linux and Windows with mix format

Hi there,
me and my friend are working on the same project and we use the mix format command to format our code. The problem is that he is working on Linux and im working on Windows and so the formatting differs. Windows uses another LineEnding than Linux.
Our pipeline uses Linux so when it checks for the formatting it only fails when I commit with my windows formatted code.
We both use VSCode.

Is there a way to have the same formatting over different operating systems?
Diogo L

Most Liked

stefanluptak

stefanluptak

Hi Diogo,

make sure friend and you both use the same line ending setting in VSCode. You can see and change it in the bottom right corner usually (that LF). Or use the “Change End of Line Sequence” command from the Command Pallete (Shift + Command + P (Mac) / Ctrl + Shift + P (Windows/Linux)).

More info: How to Get Consistent Line Breaks in VS Code (LF vs CRLF) | Boot.dev

Screenshot 2023-08-08 at 12.46.17

DiogoSL

DiogoSL

Hi @stefanluptak,

thank you for the information. I now changed all files to LF and applied the setting, to create new files with LF, in the json file in VSCode.

But the problem persists. Now the mix format --check-formatted command fails because of empty lines added by my mix format command. It is only complaining about empty lines in multiline comments using the """ notation.

When my friend uses mix format it removes those empty lines and so the mix format --check-formatted command does not fail.

cmo

cmo

You can also look at defining a .gitattributes and/or editorconfig.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: The documentation above suggests that while ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29703 241
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31194 112
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement