最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论