LoginSignup
2
1

More than 5 years have passed since last update.

[Intellij]追加されたIndent自動認識のオプションについて

Last updated at Posted at 2015-06-20

Intellij 14のあるバージョンからIntellijで初めて開いたファイルのインデントフォーマットを自動認識する機能が追加された。
この機能の動作が少しわかりづらいので、詳細を書き残しておく。

現象(Intellijの動作)

  1. Intellijで作成していないファイルをIntellijで開く
  2. ファイルへ改行を追加
  3. Intellijで設定しているインデント設定とそのファイルのインデントが違う場合、以下のようなメッセージが出る
    • This file is indented with 4 spaces instead of 2

するべき操作

  • 上のメッセージが出たとき
    • このファイルでもIntellijで設定しているインデント設定を適応したい場合(上のメッセージの場合は2spaces) → Indent with 2 spaces
    • このファイル自身のインデント設定を特別にこのファイルでのみ維持したい場合(上のメッセージの場合は4spaces) → OK
  • ファイルごとのインデント設定が一切不要な場合はSettings | Editor | Code Style | Default Indent Options | Detect and use existing file indents for editingのチェックを外す

蛇足

特定のファイル固有のインデント設定を行ってから(OKを押してから).ideaディレクトリ内でそれがどこへ保存されているかを調べたが残念ながら見つけることはできなかった。
もし間違ってOKを押してファイル固有のインデント設定をしてしまった場合、一度ファイルを移動してもう一度戻すのが簡単。

関連リンク

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1