按 Enter 键时 VS Code 无法正常工作

mon*_*nte 7 visual-studio-code

我正在使用 vs-code 和 vscodevim 扩展,并看到奇怪的行为,但我不确定是什么导致了这种行为。

假设我有以下代码并且想象_代表光标位置

sample = {

    "key": "some value",_  #my cursor is at the end of line
    "another_key": some value"
}
Run Code Online (Sandbox Code Playgroud)

当我在行尾按 Enter 时,逗号移至下一行,而不是停留在同一行

sample = {

    "key": "some value"
    ,                                #when pressed enter it inserts new line and moves comma to new line
    "another_key": some value"
Run Code Online (Sandbox Code Playgroud)

如何防止这种行为并使逗号保持在同一行。

这是我的键绑定文件和 vscodevim 设置文件:

// keybindings.json
[
    {
        "key": "\\ a",
        "command": "workbench.view.explorer",
        "when": "!editiorTextFocus",
    }
    ,
]
Run Code Online (Sandbox Code Playgroud)
//vscodevimsettings.json
{
    "vim.vimrc.path": "filepath",
    "vim.leader": "<space>",
    "vim.normalModeKeyBindingsNonRecursive": [
        {
            "before": [
                "<leader>",
                "a"
            ],
            "commands": [
                "workbench.view.explorer"
            ]
        }
    ],
    "vim.smartRelativeLine": true
}
Run Code Online (Sandbox Code Playgroud)

swi*_*ksz 6

太棒了;

对我来说,扩展程序vscode-styled-components导致了这个问题,禁用它就解决了我的问题。**

原答案

一般来说,这与您安装的某些扩展有关。

我尝试禁用每个扩展以找出导致此错误的原因,然后我必须将其卸载。


oss*_*cpp 0

我遇到了同样的问题,但在 MacOS 上,我认为检查https://marketplace.visualstudio.com/items?itemName=adammaras.overtype可能会对您有所帮助。