[英]Visual Studio Code: How to show line endings
如何在 Visual Studio Code(而非 Visual Studio)中顯示行尾(CR、LF)?
目前只有小的狀態欄菜單顯示/更改實際文件的行結尾。 但有時直接在每一行中看到行尾會很棒,尤其是當行尾混合在一起時(不好,但這種情況時有發生)。
我使用以下設置,但沒有一個顯示行尾。
"editor.renderWhitespace": true,
"editor.renderControlCharacters": true,
"editor.renderIndentGuides": true
是否有lineendings的設置?
我在 GitHub 上開了一個問題: Possibility to display line endings in text area #12223
Soham Kamani 為此做了擴展: code-eol
如果要將其設置為默認值,可以將此行粘貼到編輯器設置中(F1 菜單; > Preferences: Open Settings (JSON)
)
"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"
}
請注意,這只會更改新文件的默認行尾。 這不會編輯您的文件。
您可以安裝擴展程序來顯示行尾。
VS Marketplace 上有幾個可用的。
或者,如果他們的搜索移動,請嘗試此相關的 Google 搜索
在最初的答案中,我提供了Johnny Härtell 的特定擴展的鏈接。兩年后,VS Marketplace 中神秘地缺少此擴展和作者。
為了提供更好的體驗並希望在未來證明這個答案,我已經用搜索結果更新了它,應該讓我們非常接近相關的擴展。
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" : "¤¬",
}
看起來像這樣:
我使用了“查找”並簡單地對“\n”進行了正則表達式搜索。 這似乎以簡單但有用的方式顯示新行。 希望這可以幫助。
在 Visual Studio Code 中設置默認行尾值的另一種方法:
end of line
Files: Eol
下拉菜單中設置所需的值截屏:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.