monte
monte

Reputation: 1885

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
}

Upvotes: 8

Views: 20679

Answers (7)

Abhinav Radhakrishnan
Abhinav Radhakrishnan

Reputation: 11

I had the same issue before and i figured out that it was actually the problem of an extension named Save typing which is used to automatically save the code but now vs code have it as built in feature. so when i disable the above mentioned extension everything went back for normal. If this error happens make sure to check all the extensions you have installed . Thankyou.....

Upvotes: 1

Shwe
Shwe

Reputation: 469

To me, it was "Python Indent" that caused the issue.

Upvotes: 0

Zain Saleem
Zain Saleem

Reputation: 201

Easiest non-debug solution is to click on "Extensions" and reload them one by one.

Upvotes: 0

swiksz
swiksz

Reputation: 98

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.

Upvotes: 8

Lucifer
Lucifer

Reputation: 147

Solution

In your settings.json add

"editor.acceptSuggestionOnEnter": "on"

Or,

"editor.acceptSuggestionOnEnter": "smart"

If you want to turn it off ( I don't know why would you do that )

"editor.acceptSuggestionOnEnter": "off"

Reload vscode and you're good to go

Explanation

editor.acceptSuggestionOnEnter

Controls whether suggestions should be accepted on Enter, in addition to Tab. Helps to avoid ambiguity between inserting new lines or accepting suggestions.

Upvotes: 2

Tejj
Tejj

Reputation: 191

One work around is "ctrl + Enter" instead of only pressing enter. Try this

Upvotes: 6

ossamacpp
ossamacpp

Reputation: 686

I had the same issue but on MacOS, thought it might be helpful for you to check https://marketplace.visualstudio.com/items?itemName=adammaras.overtype.

Upvotes: 0

Related Questions