End of the Line
End of the Line is a Visual Studio extension that shows end of line markers in text editor allowing users to differentiate between CR LF and LF line endings.
Visual Studio provides the Edit ▸ Advanced ▸ View White Space (Ctrl+R, Ctrl+W) option to visualize spaces and tabs. Unfortunately this option does not visualize line break characters such as carrage returns (CR) and line feeds (LF). The End of the Line is a Visual Studio extension fixes this. When used it will CR and LF characters as ¤ and ¶ respectively using the same font style as Visual Studio displays spaces and tabs in.
After installing the extension be sure to enable "View White Space" (Ctrl+R, Ctrl+W) to see the end of line markers in the text editor or specify when you wish line endings to be visible in Tools ▸ Options... ▸ End of the Line. If you encounter any difficulties take a look at the troubleshooting guide.
You can use Edit ▸ Advanced ▸ Make line endings CR LF (Ctrl+R, Ctrl+C), or Edit ▸ Advanced ▸ Make line endings LF (Ctrl+R, Ctrl+L) to change the line endings for the document as a whole or for the text selection if any.
Sources of inconsistent line endings
Have you ever wondered why Visual Studio starts showing the Inconsistent Line Endings when you open a file, even though you've only ever used Visual Studio to edit the file? Detecting where these inconsistent line endings originate from is a lot easier when you're able to see the line endings while editing the file. Common ways in which inconsistent line endings gets introduced is:
- Copying and pasting code from a file with different line endings.
- Using Visual Studio extensions that always assumes CR LF endings to reformat regions of code.
End of the line 1.5
- Support VS2017 (15.0).
- Support configuring line endings to show up in the color used for errors.
End of the line 1.4
- Add Options page for configuring visibility policy and line ending representation.
End of the line 1.3
- Support VS2015 (14.0).
- EOL markers sometimes vanished when part of compound editing operation.
End of the Line 1.2
- Editing commands for changing line endings.
End of the Line 1.1
- Only show EOL markers when show whitespace is active.
- Support VS2012 in addition to VS2013.
- EOL marker on first view line vanished when editing second line.
End of The Line 1.0
- Initial release
Contributors in the order of first contribution
Useful tools and tricks
Using text search to find inconsistent line endings
If you just want to locate places where files change from one line ending type to another, or you want to quickly check all the files in the whole solution, you can do a text search using the following regular expression:
For example, to find the locations of all line ending consistencies in the solution, do the following:
- Press Ctrl+Shift+F (Edit ▸ Find and Replace ▸ Find in Files)
\r\n.*[^\r]\n|[^\r]\n.*\r\ninto the "Find what:" edit box.
- Turn on "Find options" ▸ "Use Regular Expressions".
- Press the "Find All" button.
This will give you a find results window containing something like this:
Find all "\r\n.*[^\r]\n|[^\r]\n.*\r\n", Regular expressions, Subfolders, Find Results 1, Entire Solution, "" C:\...\ConsoleApplication1\Other.cs(1):using System; C:\...\ConsoleApplication1\Other.cs(2):using System.Collections.Generic; C:\...\ConsoleApplication1\Program.cs(9): class Program C:\...\Program.cs(11): static void Main(string args) Matching lines: 4 Matching files: 2 Total files searched: 4
You can also use the same regular expression to find inconsistencies within a single file.
Change line endings automatically when saving files
Here are two Visual Studio extensions that provide the ability to change line endings on the fly when saving files:
I (Rolf) have used Editor Config myself in the past to keep source code trees consistent across different platforms. I have no experience with Strip'em.