How to make vscode stop overriding closing parenth

2019-04-03 08:12发布

问题:

When I try to add closing parentheses, it always override the next parentheses to the right.

Here is a screen capture (it looks like I hit the right-key on the keyboard, but I'm actually inserting a new closing parentheses):

Is it possible to change this behavior?

回答1:

No, it's not possible, and this is by design. When you are typing brand-new code, and you type an opening bracket, you get the closing bracket automatically (when you have editor.autoClosingBrackets on, of course). Then, when you are finished with typing whatever you want inside those brackets, how are you going to "exit" and leave the closing bracket where it is? The most natural way is to type a closing bracket! Surely this is much easier than moving your hand all the way out to the right-arrow key or mouse to move past it.

So the feature serves as a way to help you from forgetting to type the closing bracket, not so much a way to save you from actually typing it. (Though if you do happen to navigate away for some other reason without typing it, then congratulations, you do get that bracket for free!)

The two simplest options you have if you want to add a bracket (and let me note that in your example, you'd be adding a mismatched bracket!) are to either (1) put the cursor after the cluster of closing brackets before you type a new bracket, or (2) put the cursor where you did, but just keep typing closing brackets until a new one is added. In either case, any new brackets will only be added to the end of the cluster.

For what it's worth, there's now an issue for this on the tracker.



回答2:

Try setting:

"editor.autoClosingBrackets": false

to disable the autoclosing brackets feature entirely.