When you have the cursor in front of a ]
, )
or }
and you type that character, instead of inserting it vscode just moves past that character, producing ]*cursor here*
instead of ]*cursor here*]
. Becacuse of this, every time I actually need to insert a closing bracket I need to move to the end of the ))))
to type it, instead of just being able to type it directly. So is there a way to disable this behavior(without disabling bracket auto-completion)?
Here is the same question, but for sublime text, and this guy mentions it as a side effect of auto-closing brackets.
I received a solution from github of vscode project.
It works for me. Edit your keybindings.json
add the text below:
{
"key": "]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "]"
}
},
{
"key": "Shift+]",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "}"
}
},
{
"key": "Shift+0",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": ")"
}
}
Notice: "Shift+0" for en keyboard (
, edit it for your keyboard layout.
It is indeed a side effect of the autoClosingBrackets setting of the editor.
If you go to File > Preferences > Settings to open the settings JSON file, you can search for "editor" or "autoClosing" and copy the entry to your user settings if you whish to change/disable it (it's enabled by default), or just copy this to disable it:
// Controls if the editor should automatically close brackets after opening them
"editor.autoClosingBrackets": false,
More on VS Code settings, as well as a list of the default settings can be found here: https://code.visualstudio.com/docs/getstarted/settings
If you disable this setting:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With