1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

google-java-formatをVSCode・macOS環境で利用する

Posted at

#対象とする読者
VSCode・macOS環境でのjava開発にてGoogle Java Styleに自動整形するフォーマッタ(google-java-format)を適用させたい方

#環境
macOS Catalina (version: 10.15.7)
VSCode for macOS (version: 1.53.2)

#設定法

  • ターミナルにてHomebrewでgoogle-java-formatをインストール

brew install google-java-format
  • VSCodeにて拡張機能emeraldwalk.runonsaveをインストール
    Screen Shot 2021-02-27 at 10.27.37.png

  • VSCodeにてsetting.jsonに以下の要素を追加1

{
  "emeraldwalk.runonsave": {
    "commands": [
      {
        "match": "\\.java$",
        "cmd": "google-java-format --replace ${file}"
      },
    ],
  },
}

#参考
https://www.sethvargo.com/using-google-java-format-with-vs-code/

  1. setting.jsonの開き方はコチラの記事を参照

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?