0
1

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.

VSCodeでPrettier Apex

Last updated at Posted at 2021-09-10

前段 - npmエラー解消

まずは昔のゴミか何か残っていてコマンドプロンプト上でnpm install -g npmが動かない状態だった

C:\>npm install -g npm
npm ERR! cb.apply is not a function

なので一旦以下を消した
C:\Users\XXX\AppData\Roaming\npm
C:\Users\XXX\AppData\Roaming\npm-cache

そして改めて https://nodejs.org/en/download/ のインストーラを実施して念の為コマンドプロンプトも起動し直したらnpm install -g npmが動くようになった

Prettier Apexインストール

もともと拡張機能PrettierはVSCodeに入れてあったがとにかく対象プロジェクトディレクトリにて以下を実行

C:\myapexproject>npm install -save-dev -save-exact prettier prettier-plugin-apex

VSCodeのコマンドパレットからPrettier Apexを使ってみる

VSCodeにてApexコード編集中にコマンドパレット(CTRL+SHIFT+P)にて「ドキュメントのフォーマット(Format Document)」を選ぶとフォーマットされた
ショートカットキー「SHIFT+ALT+F」でも行ける

保存時にフォーマットされるように設定する

CTRL+,(カンマ)にて設定画面を開き、「設定の検索」で「save」を入力して「Editor: Format On Save」にチェックをつける

Apexコード編集中に保存すると、フォーマットされて、それから組織にソースがデプロイされた

以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?