Does anyone tries to change the indentation to 2. ...
# ktlint
s
Does anyone tries to change the indentation to 2. Please help me here to do the same. I have already change the configuration in .editorconfig but still it’s not working
t
could you paste here your
.editorconfig
content?
s
[*] charset=utf-8 end_of_line=lf insert_final_newline=true indent_style=space indent_size=4 [{.kts,.kt}] indent_style=space tab_width=2
t
indent_size: a whole number defining the number of columns used for each indentation level and the width of soft tabs (when supported). When set to "tab", the value of tab_width (if specified) will be used.
You need to use
indent_size=2
instead of
tab_width
s
Copy code
class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
                super.onCreate(savedInstanceState)
                setContentView(R.layout.activity_main)
  }
}
This is working fine now.
But now it’s allowing multiple tabs also
t
if you run "code -> reformat code" it should remove unessesary tabs
s
Yes it is doing but I wanted to add this in pre-commit hook to make it mandatory and to avoid unwanted spacings.
t
I think ktlint has a rule that will fail in such case 🤔
s
I think I can still live with this. Thanks for your help. 🙂