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

时间:2016-09-16 06:55:34

标签: visual-studio-code

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

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

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

是否有线端设置?

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

编辑2: Soham Kamani对此进行了扩展:code-eol

5 个答案:

答案 0 :(得分:243)

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

enter image description here

答案 1 :(得分:60)

如果您想将其设置为默认值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"

答案 2 :(得分:12)

渲染行尾是一个仍在积极维护的VS 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"   : "¤¬",
}

看起来像这样:

enter image description here

答案 3 :(得分:6)

有一个扩展名显示行尾。您可以配置所用的颜色,代表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 

VS Marketplace Link

答案 4 :(得分:1)

另一种在 Visual Studio Code 中设置默认 end of line 值的方法:

  1. 导航到 Visual Studio Code 设置选项卡(例如,通过 Ctrl + (逗号))
  2. 在搜索栏中搜索end of line
  3. Files: Eol 下拉菜单中设置所需的值

截图:

Enter image description here