Est*_*ask 3 eslint visual-studio-code
当使用 Shift+Ctrl+A 添加多行注释时,行尾添加空格/*,这可能会导致 linter 问题:
我对no-trailing-spaces有关注释的 linter 规则感到满意,并且不想因为 VS Code 的怪癖而更改它。
之前的前导空间*/不会导致 linter 问题,但我想摆脱它,因为它看起来已经移位,而且我不在多行注释中使用中间星号,例如:
/*
* multiline
* comment
*/
Run Code Online (Sandbox Code Playgroud)
可以在 Visual Studio Code 中更改将空格添加到多行注释的方式吗?
编辑 v1.42(设置为“评论:插入空间”):
显然来到 v1.42 的是这个设置editor.insertSpaceAfterComment似乎可以解决您在块注释案例中的问题。但是如果禁用,则在行//注释符号后不会插入空格,所以//comment starts immediately代替// comment starts after space. 这对您来说可能会也可能不会被接受。
见https://github.com/microsoft/vscode/pull/41747
如果你有
"editor.trimAutoWhitespace": true
Run Code Online (Sandbox Code Playgroud)
当您保存文件时,它将删除尾随的空格。或者,使用该命令editor.action.trimTrailingWhitespace还将删除文件中的尾随空格Ctrl- K Ctrl- X。
修改内置片段很棘手,因为它们可以在更新时被覆盖。
您可以制作一个一次性删除空间的宏。我想你的意思是Shift- Alt- A:这是在我的 vscode 上切换块注释的命令。你在你的问题中说 Shift+Ctrl+A 对我来说是未绑定的。
使用扩展multiCommand :(在您的 settings.json 中)
{
"command": "multiCommand.blockComment",
"sequence": [
"editor.action.blockComment",
"editor.action.trimTrailingWhitespace",
"cancelSelection",
"deleteRight"
]
},
Run Code Online (Sandbox Code Playgroud)
*/根据您的要求,最后两个命令删除了前导空格。
在您的 keybindings.json 中:
{
"key": "shift+alt+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+a",
"command": "multiCommand.blockComment",
},
Run Code Online (Sandbox Code Playgroud)
然后用Shift- Alt-调用A,关闭仍然有效。
[gif 在输入的按键上有点疯狂,它只是Shift- Alt- A.]
| 归档时间: |
|
| 查看次数: |
3608 次 |
| 最近记录: |