Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code: How to show line endings

People also ask

How do I set line endings in Visual Studio?

Go to Project> Solution Options> Source Code> Code Formatting> Text File In the Line Terminations drop box select Unix/Mac. Show activity on this post. The LF is clickable and you choose either LF or CRLF. Pretty sure that visual studio code, not visual studio.

How do you show lines in VS Code?

You can show or hide line numbers in your code. Here's how. On the menu bar, choose Tools > Options. Expand the Text Editor node, and then select either the language you're using or All Languages to turn on line numbers in all supported programming languages.

What is CRLF and LF in VS Code?

End your issues with whitespace in VS Code This is typically due to a difference in line endings. Unix systems (Linux and Mac) default to the LF (line feed) character for line breaks. Windows on the other hand is “special” and defaults to CR/LF (carriage return AND line feed).

How do I change the end of line sequence in VS Code?

VS Code => Settings => Files: EoL And choose “\n” as EoL character if you would like your files to have Unix Style line endings and choose “\r\n” if you would like your files to have Windows Style line endings. VS Code — Eol Settings for Files.


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


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.


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

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


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.


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