How to stop unnecessary indent on a new line?

How do I get Datagrip to stop adding an unnecessary indent on a new line?

For example, I want this….

line 1: -- This is a comment without an unnecessary leading indent
line 2:    -- This is comment on a new line WITH an necessary leading ident added by Datagrip
line 3:        -- After hitting RETURN
line 4:            -- As you can see these unnecessary indents are really annoying and
line 5:                -- contribute nothing of value
line 6:                    -- How do I stop this nonsense so I don't waste my time removing
line 7:                        -- all of these unnecessary indents in my code?

to be this…

line 1: -- This is a comment without an unnecessary leading indent
line 2: -- This is comment on a new line WITH an necessary leading ident added by Datagrip
line 3: -- After hitting RETURN
line 4: -- As you can see these unnecessary indents are really annoying and
line 5: -- contribute nothing of value
line 6: -- How do I stop this nonsense so I don't waste my time removing
line 7: -- all of these unnecessary indents in my code?

without me constantly going back and removing all of the indents

2
7 comments

Chris1058wright thank you. All of those options are already turned off. Yet I still get automatic indentation. 

0
Please specify all the options you have turned off to better diagnose the configuration settings. Additionally, you need to check if you have smart ident or any other indent options enabled in Smart Key under File | Settings | Editor | General | Smart Keys
1

Aleksandr Molchanov The number of indent,wrap,chop options in the code style section is huge. Asking me to manually list them all seems unreasonable. I have attached my current code style XML.

<code_scheme name="Oracle" version="173">
  <option name="OTHER_INDENT_OPTIONS">
    <value>
      <option name="INDENT_SIZE" value="2" />
      <option name="TAB_SIZE" value="2" />
    </value>
  </option>
  <option name="RIGHT_MARGIN" value="240" />
  <option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
  <option name="SOFT_MARGINS" value="120,240" />
  <SqlCodeStyleSettings version="7">
    <option name="USE_GENERAL_STYLE" value="true" />
    <option name="KEYWORD_CASE" value="5" />
    <option name="IDENTIFIER_CASE" value="1" />
    <option name="TYPE_CASE" value="4" />
    <option name="ALIAS_CASE" value="1" />
    <option name="BUILT_IN_CASE" value="4" />
    <option name="QUOTE_IDENTIFIER" value="1" />
    <option name="QUERY_EL_COMMA" value="1" />
    <option name="QUERY_IN_ONE_STRING" value="1" />
    <option name="SUBQUERY_OPENING" value="1" />
    <option name="SUBQUERY_CONTENT" value="1" />
    <option name="SUBQUERY_CLOSING" value="4" />
    <option name="SUBQUERY_PAR_SPACE_BEFORE" value="1" />
    <option name="INSERT_INTO_NL" value="2" />
    <option name="INSERT_CONTENT" value="0" />
    <option name="INSERT_TABLE_EL_LINE" value="1" />
    <option name="INSERT_VALUES_EL_LINE" value="1" />
    <option name="INSERT_EL_WRAP" value="0" />
    <option name="INSERT_EL_COMMA" value="1" />
    <option name="SET_EL_LINE" value="1" />
    <option name="SET_EL_COMMA" value="1" />
    <option name="WITH_EL_LINE" value="1" />
    <option name="WITH_EL_COMMA" value="1" />
    <option name="WITH_ALIGN_AS" value="true" />
    <option name="SELECT_EL_LINE" value="1" />
    <option name="SELECT_EL_COMMA" value="1" />
    <option name="SELECT_KEEP_N_ITEMS_IN_LINE" value="3" />
    <option name="SELECT_ASTERISK_REGULAR" value="true" />
    <option name="FROM_EL_LINE" value="1" />
    <option name="FROM_EL_COMMA" value="1" />
    <option name="FROM_ALIGN_JOIN_TABLES" value="true" />
    <option name="FROM_ALIGN_ALIASES" value="true" />
    <option name="FROM_INDENT_JOIN" value="false" />
    <option name="FROM_ONLY_JOIN_INDENT" value="2" />
    <option name="FROM_PLACE_ON" value="10" />
    <option name="WHERE_EL_LINE" value="1" />
    <option name="ORDER_EL_LINE" value="1" />
    <option name="ORDER_EL_WRAP" value="2" />
    <option name="ORDER_EL_COMMA" value="1" />
    <option name="ORDER_ALIGN_ASC_DESC" value="true" />
    <option name="TABLE_OPENING" value="1" />
    <option name="TABLE_CONTENT" value="2" />
    <option name="TABLE_COLLAPSE" value="true" />
    <option name="TABLE_ALTER_INSTRUCTION_WRAP" value="2" />
    <option name="TABLE_ALTER_ITEM_WRAP" value="2" />
    <option name="TABLE_ALTER_ITEM_INDENT" value="false" />
    <option name="CONSTRAINT_WRAP_1" value="false" />
    <option name="POST_OPT_WRAP_2" value="false" />
    <option name="POST_OPT_INDENT" value="false" />
    <option name="POST_OPT_ALIGN" value="false" />
    <option name="CREATE_SCHEMA_CONTENT_INDENT" value="false" />
    <option name="CREATE_SCHEMA_BLANK_LINES_MIN" value="0" />
    <option name="VIEW_WRAP_QUERY" value="false" />
    <option name="VIEW_INDENT_QUERY" value="true" />
    <option name="ROUTINE_ARG_CONTENT" value="2" />
    <option name="ROUTINE_ARG_CLOSING" value="6" />
    <option name="ROUTINE_ARG_WRAP" value="2" />
    <option name="ROUTINE_ARG_COMMA" value="1" />
    <option name="ROUTINE_ARG_ALIGN_TYPES" value="true" />
    <option name="ROUTINE_PG_L_QUOTE_WRAP_BEFORE" value="false" />
    <option name="ROUTINE_PG_L_QUOTE_WRAP_AFTER" value="false" />
    <option name="ROUTINE_PG_R_QUOTE_WRAP_BEFORE" value="false" />
    <option name="IMP_DECLARE_CONTENT_WRAP" value="false" />
    <option name="IMP_DECLARE_EL_WRAP" value="1" />
    <option name="IMP_IF_THEN_WRAP_INNER" value="false" />
    <option name="IMP_LOOP_LOOP_WRAP" value="false" />
    <option name="IMP_LOOP_LOOP_INDENT" value="false" />
    <option name="IMP_LOOP_COLLAPSE" value="true" />
    <option name="CORTEGE_SPACE_BEFORE_L_PAREN" value="false" />
    <option name="CORTEGE_COMMA_1ST" value="true" />
    <option name="CORTEGE_SPACE_AFTER_COMMA" value="false" />
    <option name="EXPR_CASE_THEN_ALIGN" value="true" />
    <option name="EXPR_CASE_END" value="1" />
  </SqlCodeStyleSettings>
  <codeStyleSettings language="SQL">
    <indentOptions>
      <option name="INDENT_SIZE" value="2" />
      <option name="CONTINUATION_INDENT_SIZE" value="0" />
      <option name="TAB_SIZE" value="2" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>
0

FWIW, the problem still occurs when I set my current code style to the default settings for Oracle.

0
I took your formatting settings and imported them into a config schema. I could not indicate an issue with indentation as shown in your screenshots. Can you also specify your current IDE version and a screenshot with settings(not part of formatting settings) you have configured in Smart Key under File | Settings | Editor | General | Smart Keys
0

Hi kdwhite,

Had the same irritating issue and spent way too much time before I found this post. Hitting Enter after a comment (-- or /* */) indented the next line. Can confirm that Aleksandr's earlier advice regarding Smart Keys pointed me in the right direction and worked. Many thanks Aleksandr Molchanov.

I disabled Smart Indent under the Enter section in File | Settings | Editor | General | Smart Keys and now the cursor is placed at the correct indentation level (DataGrip 2026.2.6, dialect: SQLite).

0

Mike Neumann, glad I pointed you in the right direction. 

0

Please sign in to leave a comment.