Search code examples
vue.jsintellij-ideavuejs2indentationauto-indent

Intellij is using different indention within the same .vue file


In the <template> area Intellij is using 2 spaces for indention and for the <script> part it's using 4 spaces. I get errors running npm run dev because of the different indention.

I have set Intellij to use 4 spaces for all filetypes that I could find (not including JS or .vue). The project itself uses 2 spaces (I would like to change that).

However, now like I said it's using two different indention styles within the same file and that causes a whole lot of problems.

Code -> Reformat code changes the code to this style with 2 different indentions.

Any idea what's going on? Thanks!


Solution

  • First, make sure you don't have Detect and use existing file indents for editing enabled in Settings/Preferences | Editor | Code Style. If you do, when you auto-indent, it might apply the wrong settings.

    Then, try reformatting the code using Control+Alt+L or Code -> Reformat Code.