Cargo.toml with native newlines?

Can I use something like "cargo new" to create a Cargo.toml that uses native newlines?
I know that using "cargo fmt -- --config newline_style=Native" can change the newline style of the code to use native newline characters, but this does not take effect on Cargo.toml. Is there any way to make Cargo.toml apply such a schema as well?

When even Microsoft (check any file in there except the .cmd) uses the "unix line feed" as their newline delimiter, I just think you should also just use \n instead of \r\n\ regardless of your platform. PS: in french we have this expression in this situation.

You can set your text editor to always use your preferred delimiter on save. Just save your Cargo.toml and it will be as you want.


But for my case, git uses native newline characters, so on Windows, when the file uses LF, git will give a warning, I don't want this warning to appear, and I don't want to modify the configuration of git, and I also need to use the command line instead of the GUI text editor to generate Cargo.toml and commit it. So if Rust doesn't natively provide this solution, is there any other command-line solution that can force a file's newlines to CRLF?

Ok, now I wrote this: czy-29/force-crlf: Force a file to use CRLF line breaks. (


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.