sqlintellij-ideacode-formattingintellij-idea-2016

How to stop IntelliJ from reformatting SQL code?


IntelliJ reformats my SQL code when I type a closing parentheses. How do I turn this off? For example, I'm write something like:

enter image description here

Now, when I type a ')' at the right margin, to close of that common table expression, it re-writes the code like this:

enter image description here

How do I turn this off? I know I can change some things in Preferences under Editor > Code Style > SQL. For example, I can tell it not to uppercase by keywords. But I want to tell it not to reformat my code when I type a ')'. There is a checkbox to "disable formatting", but if I check that then I can't even reformat code even when I want to.


Solution

  • In Editor > General > Smart keys there is a checkbox Reformat block on typing '}'.

    It seems like it also works for ) in SQL.

    The downside is that it is a single option for all languages, so it won't work if you want a different behaviour only for SQL.