LoginSignup
38

More than 3 years have passed since last update.

VSCodeでコード整形ツール(Fomatter)を使用する

Last updated at Posted at 2018-12-26

VSCodeでコード整形ツール(Fomatter)を使用したい場合の導入方法メモ。
1. Formatterのデフォルトのショートカットキーである「Ctrl + Alt + F」キーを押下する
(Macの場合、英字モードにしてから「Shift + Option + F」を押下)
2. フォーマッターがインストールされていなければ、右下にインストールしますか?という通知が表示される
3. Yesボタンをクリックする (Installボタンだったかも)
4. pythonの場合、「$ python -m pip install -U autopep8 --user」のコマンドがターミナルに表示され、自動でautopep8のライブラリがインストールされる

これでCtrl + Alt + F(もしくは Shift + Option + F)を押すとコード整形できるようになります。

保存時にコード整形したい場合

  1. メニューからFile -> preferences -> settings
  2. formatOnで検索する
  3. Format On Saveにチェックをつける

無題.png

参考
https://code.visualstudio.com/docs/getstarted/keybindings
https://devadjust.exblog.jp/23791887/

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
38