How to correct indentation in IntelliJ

Code → Reformat Code… (default Ctrl + Alt + L) for the whole file or Code → Auto-Indent Lines (default Ctrl + Alt + I) for the current line or selection. You can customise the settings for how code is auto-formatted under File → Settings → Editor → Code Style. To ensure comments are also indented to the same level as the code, you can simply do as follows:

Indent Expected?

There are, in fact, multiple things you need to know about indentation in Python: Python really cares about indention. In other languages, indention is not necessary but only serves to improve the readability. In Python, indentation is necessary and replaces the keywords begin / end or { } of other languages. This is verified before the execution of the … Read more

How to replace tabs with spaces in Atom?

Atom has a built-in tool for this Activate the command palette (ShiftCmdP on Mac, CtrlShiftP on Windows/Linux) and search for “convert space” or “convert tab”. You should find these three commands are available: Whitespace: Convert Spaces to Tabs Whitespace: Convert Tabs to Spaces Whitespace: Convert All Tabs to Spaces Convert Tabs vs. Convert All Tabs … Read more

Tab Error in Python

You cannot mix tabs and spaces, according the PEP8 styleguide: Spaces are the preferred indentation method. Tabs should be used solely to remain consistent with code that is already indented with tabs. Python 3 disallows mixing the use of tabs and spaces for indentation. Python 2 code indented with a mixture of tabs and spaces should … Read more