无法使用Enter键在VS Code中创建换行。

huangapple go评论128阅读模式
英文:

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贡献的命令(查看键绑定源的最右侧列)

无法使用Enter键在VS Code中创建换行。

> 我将关闭此问题,因为这个扩展没有得到维护。我建议切换到
> 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)

无法使用Enter键在VS Code中创建换行。

> 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

只禁用这个扩展,问题就会解决。

英文:

无法使用Enter键在VS Code中创建换行。

Just Disable this extension and it will be fixed

答案4

得分: 0

对我来说,有效的方法是点击vscode-styled-components扩展中的“迁移”按钮。

无法使用Enter键在VS Code中创建换行。

英文:

Thought I would reply to this with my experience in case it helps anyone. For me, what worked was to hit the Migrate button on the vscode-styled-components extension.

无法使用Enter键在VS Code中创建换行。

huangapple
  • 本文由 发表于 2023年3月31日 16:00:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896153.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定