How to properly setup auto completion in JetBrains WebStorm('eat' closing quote, parenthesis, brace, etc.)?

I just started using JetBrains WebStorm, it's great and everything but I can't configure it in the way I want it to work, so it actually save more time, so I don't have type everything manually by myself and so I don't have to battle auto completion technologies by unnecessary pressing many additional keys on the keyboard.

So there are different situations in which I either have to battle auto completion technologies in order to continue to type code or I have to type every single thing:

When defining an object it doesn't 'eat' closing brace(which is on a new line), it inserts a new one and break my code:

But if this closing brace is on the same line with a cursor, it will eat closing brace:

Which doesn't make any sense: if I just type closing brace } and it break my code, then auto completion is broken; and if I have to press multiple arrow keys just in order to be able to make auto completion work or to just continue typing my code, then auto completion is counter-productive.

I wasn't able to find a solution, so it eats closing brace }(which is on a new line) and put my cursor right after the closing brace, so I can continue to type my code without doing additional job.

Here's how it looks when I do it manually(and how it should be when auto completion is turned on, just imagine that closing brace is there, on the next line):

So if I turn off my auto completion, I can actually type things without breaking my code, but I don't want to type everything manually. Once I actually want to jump to some other place using my mouse, I will have to actually finish all of these closing braces and commas, which is counter-productive compared to 'proper' auto completion solution, which I am trying to achieve.

Is there a way to use auto completion but to make it, so when I type closing brace myself, it will eat my own brace and put a cursor right after the next closing brace IDE put there by itself, even if this closing brace is on the next row?

Here's an example from Visual Studio(C#) of what I'm trying to achieve in WebStorm(and how it should properly originally work):

This approach would allow me to type code manually when I want to do it without pressing additional keys on the keyboard(like Enter or Arrow keys), as well as to instantly jump to some other pieces of code using my mouse, without worrying about manually typing closing braces by myself all the time. It would make everything more comfortable, faster and less error prone.

2 comments
Comment actions Permalink

This can't be configured. 'Overtyping' (eating extra closing braces/quotes/parentheses) only work if characters are placed next to each other

0
Comment actions Permalink

Managed to make a fix: bound a macro to ctrl+}, so it moves to the end of the block and then types } itself:

That's better than default ctrl+} function because with default function I would have to press ctrl+} and then shift+} every time. Now I only have to press ctrl+} and I can continue typing without interference and battling IDE.

Of course, it would be better if it was natively supported, as in Visual Studio(shift+}), I still have to type ctrl+} instead of more logical, comfortable and default shift+}. ctrl+} macro still has it advantages, too. For example, I can leave code block from any position inside, not only from the end(as in Visual Studio):

This approach is definitely better(faster, more comfortable and intuitive) than default, I don't have to battle IDE anymore and auto completion is in place, as it should be. The only down side is that I have to press ctrl+}.

It would be also nice to have a native function(in addition to this macro), that eats your own brace when you press shift+} and then puts your cursor after the closing brace, but only if you press shift+} when there is no anything except \r\n and \t characters in-between cursor and brace itself. It could be very easily achieved with macro and a condition. Regular expression would look something like this: (\x0d?\x0a?(\x09)?)\}

But I can't find how to run macro only if some condition is met.

0

Please sign in to leave a comment.