269
votes

How can I display lineendings (CR,LF) in Visual Studio Code (not in Visual Studio)?

I use the following settings, but none of them show the line endings.

"editor.renderWhitespace": true,
"editor.renderControlCharacters": true,
"editor.renderIndentGuides": true

Is there a setting for lineendings?


I've opened a issue on GitHub: Possibility to display line endings in text area #12223

Soham Kamani made an extensions for this: code-eol

5
I've made an extensions for this in case you still need it : marketplace.visualstudio.com/… - Soham Kamani
@SohamKamani Your comment should be the accepted answer to the question. - Nicolas Seiller
That extension is useless: it doesn't actually display whether characters are carriage returns or line feeds, it just makes glyphs at the end of the lines which match what vscode says the file is. It doesn't help pinpoint files with mixed end-of-line styles. (That or vscode is automatically normalizing the files' EOLs, thus making any extension to this effect useless.) - Tustin2121
This has changed: "editor.renderWhitespace": true, true is not accepted anymore. - Timo
For "editor.renderWhitespace" valid values: "none", "boundary", "selection", "trailing", "all" as string. - mdiiorio

5 Answers

405
votes

AFAIK there is no way to visually see line endings in the editor space, but in the bottom-right corner of the window there is an indicator that says "CLRF" or "LF" which will let you set the line endings for a particular file. Clicking on the text will allow you to change the line endings as well.

enter image description here

120
votes

If you want to set it to LF as default, you can paste this line in your editor settings (F1 menu; > Preferences: Open Settings (JSON))

"files.eol": "\n"

Example:

{
    "git.confirmSync": false,
    "window.zoomLevel": -1,
    "workbench.activityBar.visible": true,
    "editor.wordWrap": true,
    "workbench.iconTheme": "vscode-icons",
    "window.menuBarVisibility": "default",
    "vsicons.projectDetection.autoReload": true,
    "files.eol": "\n"
}

Please note that this will change the default line ending for new files only. This will not edit your files.

22
votes

You can install an extension to show line endings.

There are several available at the VS Marketplace.

Or if their search moves, try this relevant Google search


In the original answer, I had provided a link to a specific extension by Johnny Härtell After two years, this extension and the author are mysteriously missing from the VS Marketplace.

To provide a better experience and hopefully future proof this answer, I've updated it with search results that should keep us pretty close to a relevant extension.

17
votes

Render Line Endings is a Visual Studio Code extension that is still actively maintained (as of April 2020):

https://marketplace.visualstudio.com/items?itemName=medo64.render-crlf

https://github.com/medo64/render-crlf/

It can be configured like this:

{
    "editor.renderWhitespace": "all",
    "code-eol.newlineCharacter": "¬",
    "code-eol.returnCharacter" : "¤",
    "code-eol.crlfCharacter"   : "¤¬",
}

and looks like this:

Enter image description here

3
votes

Another way to set the default end of line value in Visual Studio Code:

  1. Navigate to the Visual Studio Code settings tab (e.g., by Ctrl + , (comma))
  2. Search for end of line in the search bar
  3. Set the desired value in the Files: Eol dropdown menu

Screenshot:

Enter image description here