VSCode - 显示EOL字符的插件

VSCode自身没有显示EOL字符的功能,可以通过扩展插件来实现。

在插件市场搜索到: Render Line Endings

点击安装,Publisher:Josip Medved,选择相信第一次从此publisher安装程序。

This extension renders end of line characters (CR, LF, CRLF) when whitespace rendering is on.

Installation

* Press CTRL P or COMMAND P

* Write ext install medo64.render-crlf

* Press Enter

Features

* Renders end of line characters: CR, LF, CRLF

Note: CR files are not supported by VS Code. See Upstream Issues

* Only renders visible portions of text, which makes it very fast even for huge documents

* The characters used to render EOL can be customized

* Respects the value of editor.renderWhitespace

* The option can be toggled with View > Appearance > Render Whitespace or from the Command Palette

* An example with editor.renderWhitespace: selection:

* Can be configured to highlight non-standard EOL only:

* Can be configured to highlight trailing whitespace only:

* Configuration options can be set per language

* Uses colors from the current theme:

* "editorWhitespace.foreground": Rendered characters

* "errorForeground": Non-standard EOL and trailing whitespace, if configured

Settings

This extension contributes the following settings (compatible with code-eol extension):

|--------------------------------------|---------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Setting | Default | Description |
| "code-eol.newlineCharacter" | "↓" | Character used to display LF, Linux and Mac's line ending. |
| "code-eol.returnCharacter" | "←" | Character used to display CR, old Macintosh' line ending. Note: CR files are not supported by VS Code: see microsoft/vscode#35797. |
| "code-eol.crlfCharacter" | "↵" | Character used to display CRLF, Windows' line ending. |
| "code-eol.highlightNonDefault" | false | If set, non-standard line endings will be highlighted as errors. The standard EOL is taken from files.eol. |
| "code-eol.highlightExtraWhitespace" | false | If set, trailing whitespace will be highlighted as errors. |
| "code-eol.decorateBeforeEol" | false | If set, rendered characters will come before the end of the line. Note: If set, line endings will not be rendered on empty lines. |
| "code-eol.forceShowOnWordWrap" | false | If set, rendered characters will always be shown when word wrap is on, regardless of the other settings. |
| "code-eol.forceShowOnBoundary" | false | If set, rendered characters will always be shown when in boundary mode. |
| "code-eol.colors.default.foreground" | (theme) | If set, used instead of theme default for coloring EOL characters |
| "code-eol.colors.error.foreground" | (theme) | If set, used instead of theme default for highlighting different EOL characters and extra whitespace |

>Configuration Examples

Here are examples of a few most common adjustments.

>>Render All Whitespace

It's perfectly fine to use View -> Appearance -> View whitespace and for that you don't need to edit any settings. However, if you want to permanently turn whitespace on, you can do so:

{

"editor.renderWhitespace": "all",

}

>>Custom colors

You can override theme defaults, if so desired.

{

"code-eol.colors.default.foreground": "#007000",

"code-eol.colors.error.foreground": "#700000",

}

>>Alternate EOL Characters

If you don't like default characters, you can select any unicode character you like. For example, if you want it to look similar to Atom, you can use something like this:

{

"code-eol.newlineCharacter": "¬",

"code-eol.returnCharacter" : "¤",

"code-eol.crlfCharacter" : "¤¬",

}

(default characters are ↓, ←, and ↵).

Highlight Non-standard EOL:

If you want to highlight files that have different ending than defined in files.eol, you can set code-eol.highlightNonDefault:

{

"code-eol.highlightNonDefault": true,

}

Highlight Trailing Whitespace Only:

If you want to highlight trailing whitespace (either spaces or tab), there's a setting for that:

{

"code-eol.highlightExtraWhitespace": true,

}

>Upstream Issues

Please upvote the following VS Code issues:

Mixed Line Endings Are Not Supported (microsoft/vscode#127)

VS Code normalizes line endings of mixed files upon load, and thus this extension will always show one kind of EOL character.

>>CR Line Ending Is Not Supported (microsoft/vscode#35797)

VS Code does not support the CR line ending. Therefore, while you can configure it, you will never see CR as a line ending.

>>Not Rendering Glyphs For Large Files (microsoft/vscode#27100)

For performance reasons VS Code doesn't synchronize files that are over 5MB in size. Therefore, no line-ending characters will be visible on large files.

To avoid this you can set:

"editor.largeFileOptimizations": false

// some other symbols you might want to use:

// ¤

// ↓

// ←

// ↙

// ⇣

// ⇠

// ⇓

// ⇐

// ▼

// ◀

// ␤

// ¶

// ↲

// ↩

// ↴

// ⬎

// ⇂

// see more at https://unicode-table.com/en/sets/arrows-symbols/

相关推荐
AI进化营-智能译站5 小时前
Jazzy ROS2入门指南系列05-配置VsCode实现ROS2项目开发
ide·vscode·ai·编辑器
EvenBoy10 小时前
IDEA中使用CodeX
java·ide·intellij-idea
时光之源10 小时前
Visual Studio | Marketplace创建发布者(Create Publisher)时无法创建的问题解决方案
ide·vscode·visual studio·plugin·cursor
Aray123411 小时前
VS Code 中使用 Claude Code 调用 GPUStack 本地大模型及 ECC 安装教程
vscode·ecc·gpustack·claude code
小短腿的代码世界13 小时前
Qt量化策略编辑器深度解析:从DSL解析到可视化编排的完整架构
qt·架构·编辑器
咬人喵喵13 小时前
五一劳动节 SVG 交互图文案例大全
低代码·微信·编辑器·交互·svg
啾啾啾66613 小时前
VScode用cookie登录时,输入cookie值后按回车没反应
ide·vscode·编辑器
iwS2o90XT14 小时前
开发一个VS Code主题插件,定制你的IDE
ide·jupyter·postman
Misnice14 小时前
Cursor 常用快捷键总结
编辑器
yc_12241 天前
用 Visual Studio 远程调试 Linux:从零到流畅的完整指南
linux·ide·visual studio