最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

IntelliJ - Tab indentation in Javascript does not work - Stack Overflow

matteradmin7PV0评论

I want to use tabs for indentation in my Javascript files. I changed the configuration as usual, but the preview doesn't seem to take my modification in account. Neither in the acutal files.

What is surprising is that the "Spaces" subtab is formatting the code the right way, but it's is the only place where it works. (See screenshots below)

Did anyone have the same issue ?

I am using IntelliJ Ultimate 2016.1

I want to use tabs for indentation in my Javascript files. I changed the configuration as usual, but the preview doesn't seem to take my modification in account. Neither in the acutal files.

What is surprising is that the "Spaces" subtab is formatting the code the right way, but it's is the only place where it works. (See screenshots below)

Did anyone have the same issue ?

I am using IntelliJ Ultimate 2016.1

Share Improve this question asked Apr 15, 2016 at 10:35 xureixurei 1,0868 silver badges23 bronze badges 2
  • Did you actually change the files? The setting just applies to new indentation, you'd have to reformat existing files in order to apply it retrospectively. – T.J. Crowder Commented Apr 15, 2016 at 10:40
  • Yes, I did change the files. Actually, when I press I add a new line or try to reformat a javascript file, the indentation is converted to spaces even when I check the "Use tab character" as shown on the screenshot. – xurei Commented Apr 15, 2016 at 10:46
Add a ment  | 

2 Answers 2

Reset to default 5

Take a look a editorconfig . You will need a .editorconfig file at the root of your project. It's a markup file that works accros multiple IDE's to set some mon configuration like indentation and trailing spaces. Here is an example.

root = true

[*]
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true

[*.js]
indent_size = 2

From Intellij Idea 14 onwards, IDE by default detects existing indentation styles in existing files and uses them instead of your settings. You can Turn this feature off in the prefferences:

Prefferences -> Editor -> Code Style -> Detect and use existing file indents for editing

If turning off this feature does not help, make sure your project does not have .editorconfig file, which defines indentation styles as well.

Post a comment

comment list (0)

  1. No comments so far