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.
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.
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).
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.
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:
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:
end of line
in the search barFiles: Eol
dropdown menuScreenshot:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With