英文:
Cannot create line break with Enter key in VS Code
问题
自上次更新(V1.77.0)以来,VS Code 编辑器中的 Enter 键无法用来创建换行。其他人有相同的经历吗?
英文:
Since last update (V1.77.0) the Enter key doesn't work to create a line break in VS Code editor.
Anybody else experience the same?
答案1
得分: 7
请检查这个GitHub问题:Enter键无法工作。 (以及https://github.com/microsoft/vscode/issues/178788)
vscode-styled-components 扩展已被一些人确定为问题的原因。
来自这个问题的内容:
> 这个问题确实是由
> diegolincoln.vscode-styled-components扩展引起的,原因是新的VS
> Code when-clause解析器。
>
> 我尝试向这个扩展发送PR,修复它的语法错误
> (以前的解析器只是忽略了它),但似乎这个
> 扩展(至少它的存储库)已经归档。看起来有一个新的vscode-styled-components扩展,非常受欢迎 -
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components
>
> 解决方法 选项1(建议)
>
> 这个特定扩展似乎没有得到维护。我强烈建议
> 切换到使用这个扩展,如果它符合您的需求 -
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components
>
> 选项2
>
> 删除该绑定键:调用“首选项:打开键盘快捷键”命令,搜索“enter”,然后右键单击由vscode-styled-components贡献的命令(查看键绑定源的最右侧列)
> 我将关闭此问题,因为这个扩展没有得到维护。我建议切换到
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components,
> 它似乎非常活跃,可以修复这个键绑定的几种方式(包括语法错误和与自动完成的集成)
英文:
Also check this github issue: Enter key is not working. (And https://github.com/microsoft/vscode/issues/178788)
The vscode-styled-components extension has been identified by a few people as the problem.
From the issue:
> This problem indeed is caused by the
> diegolincoln.vscode-styled-components extension because of the new VS
> Code when-clause parser.
>
> I tried sending a PR to this extension fixing the syntax error it has
> (which was just ignored by the previous parser), but it seems the
> extension (at least its repository) is archived. It seems like there's
> a new vscode-styled-components extension that's very popular -
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components
>
> Workarounds Option 1 (recommended)
>
> This particular extension seems unmaintained. I strongly suggest
> switching to using this extension if it fits your needs -
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components
>
> Option 2
>
> Remove that keybinding: invoke "Preferences: Open Keyboard Shortcuts"
> from the Command Palette, search "enter", and right-click on the
> command contributed by vscode-styled-components (see right-most column
> for the source of the keybinding)
> I will close this issue because this extension is unmaintained. I
> recommend switching to
> https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components,
> which seems to be very active and fixes this keybinding in several
> ways (both the syntax error and integration with auto-completion)
答案2
得分: 1
我找到了解决方案。
在键盘快捷方式JSON文件(keybindings.json文件)中,我添加了这个内容:
{
"key": "enter",
"command": "type",
"args": {
"text": "\n"
},
"when": "editorTextFocus && !suggestWidgetVisible"
}
现在,Enter键在代码编辑器中按预期工作。
英文:
I figured out the solution.
In the keyboard shortcuts JSON (keybindings.json file) I added this:
{
"key": "enter",
"command": "type",
"args": {
"text": "\n"
},
"when": "editorTextFocus && !suggestWidgetVisible"
},
Now the Enter key works as expected in the code editor.
答案3
得分: 0
只禁用这个扩展,问题就会解决。
答案4
得分: 0
对我来说,有效的方法是点击vscode-styled-components扩展中的“迁移”按钮。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论