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

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
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement