360

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

At the moment there is only the little statusbar menu which display/change the line ending if the actual file. But sometimes it would be great to see the line endings directly in every line especially when there are mixed line endings (not good, but this happens from time to time).

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
  • 31
    I've made an extensions for this in case you still need it : marketplace.visualstudio.com/… Feb 17, 2018 at 11:47
  • 1
    @SohamKamani Your comment should be the accepted answer to the question. Jul 11, 2018 at 9:40
  • 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
    Oct 26, 2018 at 16:32
  • 3
    This has changed: "editor.renderWhitespace": true, true is not accepted anymore.
    – Timo
    Jan 1, 2021 at 15:43
  • 2
    For "editor.renderWhitespace" valid values: "none", "boundary", "selection", "trailing", "all" as string.
    – mdiiorio
    Feb 1, 2021 at 8:03

8 Answers 8

464

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

8
  • 31
    Can you change the default value for this? Right now every time I open a File I have to manually click on this. Oct 26, 2016 at 11:31
  • 27
    @DavidMartinez Yes. In user or workspace settings: // The default end of line character. "files.eol": "\r\n",
    – Llewey
    Oct 26, 2016 at 13:43
  • 5
    @Llewey But this is a global change right? Can I set it somehow only for .sh files ? Jun 7, 2018 at 8:24
  • @KostasDemiris I haven't tested this but you could try doing "[sh]": { "files.eol": "\n" }. Not all settings can be set for a specific language and I'm not sure if this is one that can but it's worth a try. Jun 18, 2020 at 17:26
  • 12
    Doesn't answer question, which is about displaying the line endings
    – G Huxley
    Aug 10, 2020 at 2:12
139

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.

10
  • 27
    I've done this, but every time I open a file it still opens with CRLF and I have to manually change it.
    – pixelwiz
    Aug 14, 2017 at 18:02
  • 1
    @pixelwiz if you save the file does it change to LF? github.com/Microsoft/vscode/issues/26626 github.com/Microsoft/vscode/issues/2957 I changed to mac, so I do not have this issue anymore when developing on my own projects. So I cant verify, sorry. Sep 8, 2017 at 17:12
  • 9
    Same for me on Windows - setting files.eol user settings to "\n" but files are still reported as CLRF
    – Marko
    Nov 29, 2017 at 8:54
  • 2
    I've just tested this successfully with Win 10 and VS Code 1.20.1. New file got created with LF line break!
    – iaforek
    Mar 5, 2018 at 10:42
  • 1
    On creating new files, they VSCode opens with LF settings. But same as @pixelwiz and for when I open existing files from a project. Ideas how to open existing files with LF as well?
    – ZenVentzi
    Mar 7, 2020 at 19:24
78

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

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

2
  • I'm getting "unknown configuration setting" May 30 at 2:57
  • @JohnBalvinArias Did you install the extension? May 30 at 6:27
26

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.

7
  • 4
    At present, this extension doesn't do what it purports to. In a file of mixed line endings, it shows line endings as if they were all consistent, based on what VS Code claims the file is following. Jun 17, 2019 at 12:40
  • @AndrewArnott thanks for the update, we'll have to watch the issue you've submitted... github.com/jhartell/vscode-line-endings/issues/1
    – Shanimal
    Jun 17, 2019 at 19:23
  • @AndrewArnott could you tell why it does not work for you?, for me it works perfect, just the icons are small Jul 9, 2019 at 5:21
  • @JohnBalvinArias The issue I filed that Shanimal linked to describes the problem: It doesn't actually reveal mixed line endings. It always shows them as if they were consistently whatever VS Code's preference is set to. Jul 10, 2019 at 12:49
  • 5
    @AndrewArnott This is because VSCode itself does not support mixed line endings. github.com/Microsoft/vscode/issues/127
    – CatDadCode
    Jul 31, 2019 at 19:27
6

I used the "find" and simply did a Regex search for "\n". Which seems to show the new lines in a simplistic but useful manner. Hope this helps.

2
  • Ctrl+H
  • Activate "regular expression" (Alt+R)
  • Find by "\n"

enter image description here

1
  • 1
    Perfect, underrated answer!\n Thanks!
    – Joel Gray
    Nov 10 at 17:25
1

Having the opposite problem? How to hide line endings:

Oddly I have the opposite problem! I just ended up with the following highlighting of each newline - which I've never seen before. In all open files and without a selection. Assumed I'd hit a shortcut by mistake, which is how I ended up on this question. Given that the feature doesn't seem to actually exist I resorted to closing and reopening and they went away!

enter image description here

2
  • 1
    That's an odd one! I would open user settings json, copy the whole lot into notepad++ (if on windows), then get a copy of the default user settings json, also copy the whole lot into notepad++, then reset all the settings in vscode and do a diff on both those to see what changed. Don't suppose you made a separate question so people can actually find your post if they have the same issue? Please link it if you did.
    – Corné
    Feb 21, 2022 at 20:51
  • No just reopening fixed it by the look of it. So I think VSCode just glitched out. Feb 22, 2022 at 4:34
0

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

1
  • 8
    The question was how to display the current line ending, not how to change it. May 17, 2021 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.