IntelliJ IDEA 14 Will Detect Code Styles on the Fly

Posted on by Andrey Cheptsov

If you’ve already tried the latest IntellIJ IDEA 14 EAP build, you might’ve noticed that the Code Style settings offers a new option: Detect and use existing file indents for editing (enabled by default.)

This new option lets IntelliJ IDEA detect certain Code Style settings (such as Use Tab character and Indent size) in the currently edited file on the fly. It means that even if a file has a code style different from your current settings, they will still be preserved.

So now you don’t need to worry about losing the formatting in files that are specific to certain files in your project that differ from the others.

We hope you’ll find these improvements useful. Your feedback as always is welcome, so don’t hesitate to share it in our discussion forum as well as report any bugs directly to the issue tracker.

Develop with Pleasure!

Comments below can no longer be edited.

14 Responses to IntelliJ IDEA 14 Will Detect Code Styles on the Fly

  1. Andriy Bazanov says:

    October 14, 2014

    Works bad for me in PHP file (PhpStorm v8.0.2 EAP build 139.14 on Windows 7).

    It ALWAYS uses spaces.

    Extremely likely because it sees spaces (as first whitespace character) in PHPDoc comments:

    <?php
    /**
     * Leading space before asterisk in this line
     */
    

    And since at least one PHPDoc comment will always be (if user follows common practice) before any other real code/indent …

    • Yaroslav Lepenkin says:

      October 15, 2014

      From code you attached, detector shouldn’t detect anything and your code style settings will be used.

      Please, specify your code style settings and fill the request: https://youtrack.jetbrains.com/issues/IDEA

  2. andre says:

    October 14, 2014

    Woah! That’s an awesome feature!

  3. Adron Hall says:

    October 14, 2014

    Oh man, I’m very stoked about this feature and the possibilities that come along with it. I use the code style features frequently under the current version in WebStorm, and I hope that this feature gets put into that IDE soon too! Are there any plans for that?

    • Andrey Cheptsov says:

      October 15, 2014

      It’s already available in WebStorm 9 EAP.

  4. Marc Stock says:

    October 17, 2014

    This is cool but the formatting feature that I really want is where files can be viewed in one style and saved in another. Some places have styles I really don’t like and it would be fantastic if I could pick a style for viewing only.

  5. Bohuslav Burghardt says:

    October 17, 2014

    I like this feature! But I noticed one thing which seems odd:

    Let’s say I have a file indented by 4 spaces. Then I do search and replace to make it 8 spaces. But when I hit Enter for example, the IDE still thinks that the file has 4 space indentation and indents accordingly. After I close and reopen the file, correct indentation of 8 spaces is detected and used.

    Is this deliberate? Or should IntelliJ detect such changes on the fly without reopening the file?

  6. Anton says:

    October 18, 2014

    I wait for this to be in AppCode & CLion

  7. aga says:

    November 17, 2014

    cool feature!
    Anyhow, since I am still using 13.1 and do not want to switch now, could you tell me if there is any plugin with that functionality?

    • Simon says:

      November 22, 2014

      There is the editorconfig plugin, which uses a configuration file to specify your coding style for each file type.

  8. zivl says:

    October 6, 2015

    A step to the right direction, but don’t stop.
    I would appreciate if editor/refactoring respects style of already writen code/text near (surrounding) the edited statement/line. Not one indentation for whole file. Mixed indentation is the reality I have to live with. That makes me no problem than editing in an editor enforcing one formal style without respecting style of a closest context.
    I’m looking forward for the next step that way.
    Thank you for doing work joyful!

Subscribe

Subscribe for updates