save text files with the newline convention present in the file when opened
This suggestion is migrated to Developer Community. Please use below link to view the current status.
The Visual Studio text file editor has an "advanced save" option that allows me to choose a particular format to save to, every time I save a file.
However, 99% of the time, the right thing to do is to save the file using whatever convention was present when the file was originally opened. Thus, if I open a file with LF-style line termination, new lines I add should be terminated with LF, and the file should be saved as LF-terminated. If I open a file with CRLF convention, new lines I *** should be terminated with CRLF, and it should be saved CRLF terminated. Repeat for each convention you want to support.
Currently, the text editor inserts CRLF for newlines, no matter what the convention in the file was when opened. This generates files with mixed-convention line endings, which is a terrible thing to work with.
Users should not have to know which convention is present in a file when opening, and then be forced to choose that convention when saving, to have the right thing happen. Users should also not have to choose a particular convention in a "convert to" menu before saving. Both of those options add significant, continuous, drag on workflow, and, being manual steps, cause errors to be made.
Visual Studio can detect the convention automatically, and can automatically do the right thing, and would be a much better text editor if it did.
New files can be created using whatever default you want (CRLF, for example) without user intervention. It's the insistence on inserting CRLF into files that are not loaded with CRLF endings that's the biggest sin.
We are currently evaluating whether we can include this feature in a future version of Visual Studio – thank you for your feedback!
Program Manager, Visual Studio Editor Team
Still no progress on this? Notepad++, and just about every other usable text editor, does this so why can't VS?
Wow. Just wow. Almost three years to start reviewing, and then three more to finally decide to work on it? C'mon, just bust it out already!
Chris Schaller commented
Use .editorconfig to define strict rules for your IDE, see http://editorconfig.org
We found that across our team different types of projects and different users had mismatches between the .editorconfig file and their VS settings. The simple solution was to modify .editorconfig so that for all files end_of_line is crlf.
They have VSLinux now but haven't fixed this issue?
This is a huge problem for unity developers. Unity always throws warnings when the lines are inconsistent (PS they always are) to the point where I basically have to ignore warnings. I recognize that I can do this manually per file - but I shouldn't have to do it per file every single time I save the project.
I don't care what the line endings are - I just want these warnings gone from unity and my stack traces to be correct. Automatically normalizing them seems to be the obvious solution.
yes this is annoying and not an issue now in the mind of the ide developers. it is stashed on the web and forgotten.
Chris Burns commented
Seriously ... get it together, guys. It's 2018 and your flagship dev product inserts windows line endings into files that are completely unix line ended. Sure, I can explicitly save each time I edit, but god help me if I just wanna hit ctrl-s. By the time a child is 3 years old it knows not to take a dump on the floor. How long will the visual studio team take to teach this product what every toddler knows? :(
Mick A commented
When will you add this? I was looking for an extension for this but apparently only VSCode has the ability to do this, why can't I find something for the regular Visual Studio?
Actually we have here CR/LF for Cpp files and LF for CMake. In VS2017 something is seriously wrong with the inconsistent line handling. The CMakes at my current project pop up around 10 dialogs and ask me about correction of the inconsistencies every reload of the CMake solution.
Some improvement here would be nice..
Daniel Sears commented
For Visual Studio Code, the relevant settings are:
Daniel Sears commented
After two years, it seems fair to expect something from Microsoft about the status of this request.
Bill Weinman commented
Just to be clear, Microsoft's irrational insistence on using CRLF line endings has been an issue since the VERY BEGINNING OF MS-DOS. Even Apple saw the light and switched to LF-only line endings over 20 years ago. Seriously folks, how hard can this be?
A feature to set your preferred line ending style for new lines, and a feature to convert existing line endings in the open file / files / solution. These are incredibly important, low-hanging, features that are apparently absent. It's been over 5 years since this thread was opened, and from what I can find, other people opening up threads about this today are having them closed as duplicates of this one.
How much longer do we have to wait to get this very basic and much needed feature??
Rahul Sisondia commented
Please provide this feature. It is one of the most annoying issues with VS.
Dino Buljubasic commented
this is a very annoying issues if you work in both VS and VS for Mac
Evgeny Vrublevsky commented
It's a very important feature. Also it should be possible to configure which line endings are preferable on per project basis. And it would be nice to be able to configure line endings even for vcxproj files (to use \n instead of \r\n).
Just started looking for a way to auto-format to specific line endings. I'm really disappointed it isn't there...
Victor Tavares commented
+1 This is neccesary
Roger Stegeby commented
Can't believe this isn't already in place..