visual-studio-code

vs code not working properly when pressing enter


I am using vs-code along with vscodevim extension and seeing strange behaviour and I am not sure what's causing that behaviour.

Suppose I have a following code and imagine _ represents cursor position

sample = {

    "key": "some value",_  #my cursor is at the end of line
    "another_key": some value"
}

When I press enter at the end of the line, the comma moves to next line instead of staying on the same line

sample = {

    "key": "some value"
    ,                                #when pressed enter it inserts new line and moves comma to new line
    "another_key": some value"

How can prevent this behaviour and make the comma stay at same line.

Here are my keybindings file and vscodevim settings file:

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

Solution

  • tldr;

    For me, the extension vscode-styled-components was causing this problem, disabling it solved to me.**

    Original Answer

    In general, it's related to some extension you've installed.

    I tried to disable each extension to figure out which was causing this error and then I had to uninstall it.