Visual Studio代码:如何显示行结尾

ton*_*nka 168 visual-studio-code

如何在Visual Studio代码中显示lineendings(CR,LF)(不在Visual Studio中).

我使用以下设置,但不使用它们显示行结尾.

"editor.renderWhitespace": true,
"editor.renderControlCharacters": true,
"editor.renderIndentGuides": true
Run Code Online (Sandbox Code Playgroud)

是否有线端设置?

编辑1:

我在github上打开了一个问题https://github.com/Microsoft/vscode/issues/12223

编辑2:

Soham Kamani对此代码进行了扩展

问候Tonka

Lle*_*wey 301

AFAIK无法直观地看到编辑器空间中的行结尾,但是在窗口的右下角有一个指示符"CLRF"或"LF",它可以让您设置特定文件的行结尾.单击文本也可以更改行结尾.

在此输入图像描述

  • @DavidMartinez是的.在用户或工作区设置中://默认的行尾字符."files.eol":"\ r \n", (11认同)
  • 你能改变这个的默认值吗?现在每次打开文件我都要手动点击这个. (9认同)
  • 不回答有关显示行结尾的问题 (6认同)
  • @Llewey但这是一次全球性的改变吗?我能以某种方式仅为`.sh`文件设置它吗? (3认同)

Isa*_*eur 75

如果要将其设置为默认值LF,可以转到文件 - >首选项 - >设置,在用户设置下,您可以将此行粘贴到其他用户设置下方.

"files.eol":"\n"

例如.

"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"
Run Code Online (Sandbox Code Playgroud)

  • 我已经完成了这个,但每次打开文件时它仍然会打开CRLF,我必须手动更改它. (9认同)
  • 在Windows上对我来说也是一样 - 将files.eol用户设置设置为"\n"但文件仍然报告为CLRF (4认同)
  • 我刚刚用 Win 10 和 VS Code 1.20.1 成功测试了这个。使用 LF 换行符创建了新文件! (2认同)

fri*_*mle 18

Render Line Endings是一个仍在积极维护的 Visual Studio Code 扩展(截至 2020 年 4 月):

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

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

它可以这样配置:

{
    "editor.renderWhitespace": "all",
    "code-eol.newlineCharacter": "¬",
    "code-eol.returnCharacter" : "¤",
    "code-eol.crlfCharacter"   : "¤¬",
}
Run Code Online (Sandbox Code Playgroud)

看起来像这样:

在此处输入图片说明


Sha*_*mal 14

有一个扩展名显示行尾。您可以配置所使用的颜色,代表CRLF和LF的字符以及将其打开和关闭的布尔值。

Name: Line endings 
Id: jhartell.vscode-line-endings 
Description: Display line ending characters in vscode 
Version: 0.1.0 
Publisher: Johnny Härtell 
Run Code Online (Sandbox Code Playgroud)

VS Marketplace链接

  • @AndrewArnott这是因为VSCode本身不支持混合行结尾。https://github.com/Microsoft/vscode/issues/127 (4认同)
  • 另外https://marketplace.visualstudio.com/items?itemName=jeff-hykin.code-eol (3认同)
  • 目前,此扩展程序并未实现其声称的功能。在混合行尾的文件中,根据VS Code声明文件所遵循的内容,它显示行尾就好像它们都是一致的。 (2认同)

小智 8

我使用“查找”并简单地对“\n”进行了正则表达式搜索。这似乎以一种简单但有用的方式显示了新的线条。希望这可以帮助。