What does 'inconsistent line ending' mean in Visual Studio 2010? - visual-studio

What does 'inconsistent line ending' mean in Visual Studio 2010?
I also see this error in a dialog when I'm coding in VS2010. How can I stop this error from showing in the dialog?

Windows, Unix, and older Mac OSs use different line endings. (Newer MacOS uses the Unix convention).
Windows uses CR/LF, Unix uses only LF.
Visual Studio is telling you it found messed up line endings on your file, indicating it was probably edited on different operating systems, and has fixed them all for you to be consistent. If you're getting that message more than once per file, then you have to stop whatever is causing the line endings to get borked in the first place, which is most likely not Visual Studio but some other editor.

Billy and Sean has already described the cause of the problem, however one potential fix is to set up your version control system to enforce the correct line endings for .h and .cpp files. For instance if you're using Subversion then this is a matter of setting the svn:eol-style property to native. You can also do File -> Advanced Save Options to force the EOL style for each file you have problems with.

Microsoft's response from http://connect.microsoft.com/VisualStudio/feedback/details/538108/inconsistent-line-endings-dialogue-in-ide:
What that usually means is that you have lines ending with something other than a carriage return/line feed pair. It often happens when you copy and paste from a web page into the code editor.
Since you're developing in Visual Studio, you'll obviously want to choose "Windows" from the drop down.

Related

VS2015 Changes my files whenever I open them

I'm not sure what setting has changed or what is going on here, but whenever I open a file in Visual Studio Community 2015 it shows pending changes immediately.
Does anyone know what is going on here? It's really getting annoying and keeps messing up my version control with all these changed files that haven't changed.
Dammit. Just found my answer. It's actually a plugin called PHP Tools that I use. It's changing the Line Endings to Unix LF on open. Changed it to "Keep Current Settings" and it's not doing it now.
Mystery solved.

Visual Studio Solution Explorer extension to rename file but NOT extension?

Windows Explorer has a small (but great!) feature that Visual Studio does not:
When you rename a file in Windows Explorer on Windows 7 (for sure, I think for Vista and later) it selects only the main part of the filename, and not the file extension. It makes the assumption that 90% of the time, you don't want to change the file extension and saves you from the choice of using the mouse to select the relevant part to rename (bad) or having to retype the file extension (also bad).
Of course this is only if you have file extensions displayed in Windows Explorer, but if you're browsing Stack Overflow I would make an educated guess you're in the "Show me the extensions" camp.
Is there an extension for Visual Studio that provides this same functionality? Extensions seem to be getting longer and longer. Today we have .cshtml at 7 characters, who knows what we will have in the future.
As of this writing, I am talking about an extension for Visual Studio 2010. I have not gotten to play with the Visual Studio 2012 Release Candidate yet, so if this feature is baked in there I would accept assurances that I'll get it when I upgrade as an answer as well.
This is the current behavior of Visual Studio, and has been for a while, so when you press F2 to rename a file in the solution explorer it will highlight the name without the extension.
However, today I noticed it started selecting the whole file with extension, like mentioned by #DLeh in the comments. Turns out it was related to a specific project, so to me the solution was to delete the .vs folder, as explained in this answer.

Visual Studio 2005 - strange characters rendered for ANSI text

Has anyone seen this odd text rendering issue in VS2005 before?
image http://tinyurl.com/3y2ebze
The first line of using statements actually says "using System;". If I copy the line as it is displayed and paste into notepad, the text appears correctly, so clearly the character codes are correct. In addition, the solution compiles and runs correctly.
I was thinking it might be due to ClearCase using a different character encoding as all the solutions we're using were freshly checked-out yesterday on to a new build machine, but this is only happening in 2 of our ~30 solutions.
Incidentally the same .cs files when opened in VS2008 render correctly on this machine, could this be a corruption in VS2005?
Install latest service pack to VS2005.

Can I use different brace styles in different projects/solutions in VS2008?

I'm working with a couple of open-source projects that use different C# brace styles, and I'd like to configure VS text formatting to use different styles for each project so I can use Ctrl-K-D to reformat source code.
Is there any way I can configure Visual Studio 2008 to load a particular set of text formatting preferences along with a particular solution file?
As far as i know, there is no way to do this natively in VS 2008 (or even 2010 for that matter)
There is a resetsettings command line switch in Visual Studio which you can use to indicate what settings it should start up with. This works in 2005 and i presume it would with 2008 as well though i have personally not tried it with 2008. If you just make a bat file using this method as indicated here, that might be one workaround to your problem.
Also, there is an option to do a macro based solutions that might help you that i remember looking at in the past.You can probably check out this site which indicates how to do something very similar to what you are looking for

how to change source file encoding in csharp project (visual studio / msbuild machine)?

Is there a way to force VS to use Unicode always, instead of weird ISO-something?
I'm working on a winapp csproject using Visual Studio 2008 on Vista (Polish locale). The problem appears when I build the project on Win Server 2003 (English locale) - then Polish diacritic is gone.
I investigated that the issue is caused by improper source file encoding. It looks that source files aren't using UTF-8 encoding.
Problem: Compiler launched from command line cannot process the source file because of international characters that I’ve just added.
Solution: Save source file explicitly in UTF-8 encoding to preserve international characters.
How To:
open the problematic file in Visual Studio.
on the File menu click “Advanced Save Options“
from “Encoding” combo select “Unicode (UTF-8 …“
click OK.
You’re set. Commit to please the build server and rest of the team waiting for green.
In the latest Visual Studio 2017 the interface is changed a bit and you have to chose File -> Save [filename] As…. Then in the opened dialog you can chose Save with Encoding….
I've had the same problems with VS2015 vb.net project and solved it by adding <CodePage>1250</CodePage> marker to your vbproj/csproj file. I did it after <SchemaVersion> marker, rebuilt the project and it worked for me. I've had trouble with polish letters such as ż,ą etc.
You can also try the UTF-8 - 65001 but I didn't check if it works.

Resources