自动或使用快捷方式删除尾随空格 [英] Remove trailing spaces automatically or with a shortcut
本文介绍了自动或使用快捷方式删除尾随空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法删除 Visual Studio Code 中的尾随空格(自动或使用快捷方式)?
Is there a way to remove trailing spaces in Visual Studio Code (automatically or with a shortcut)?
我一直在命令面板和编辑器设置中寻找这个,但我找不到我要找的东西.
I've been looking for this in the command palette and in the editor settings, but I cannot find what I am looking for.
推荐答案
您可以在文件保存时间从设置启用空白修剪:
You can enable whitespace trimming at file save time from settings:
- 打开 Visual Studio Code 用户设置(菜单 文件 → 首选项 → 设置 → 用户设置标签).
- 点击 窗口右上角的图标.这将打开一个文档.
- 添加一个新的
"files.trimTrailingWhitespace": true
设置到用户设置文档,如果它不存在的话.这样您就不会直接编辑默认设置,而是添加到其中. - 保存用户设置文件.
- Open Visual Studio Code User Settings (menu File → Preferences → Settings → User Settings tab).
- Click the icon in the top-right part of the window. This will open a document.
- Add a new
"files.trimTrailingWhitespace": true
setting to the User Settings document if it's not already there. This is so you aren't editing the Default Setting directly, but instead adding to it. - Save the User Settings file.
我们还添加了一个新命令来手动触发此操作(从命令面板中修剪尾随空白).
We also added a new command to trigger this manually (Trim Trailing Whitespace from the command palette).
这篇关于自动或使用快捷方式删除尾随空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文