Hachi Blog
2026-02-08

Visual Studio Codeの設定

#vscode #tech

VSCodeに入れている拡張機能や設定を備忘として残します。

基本的にはアカウントの共有機能を使うと便利なのですが、会社のパソコンで個人のGitHubやMicrosftアカウントを紐づけてしまうと、誤爆が発生した場合悲惨なのでここに設定を残します。

導入する拡張機能

拡張機能 概要
WSL WSLでVSCodeを使うときに便利
GitLens 修正をだれが行ったかを確認する
Material Icon Theme アイコンがきれいになる
markdownlint マークダウン形式のファイルを書く時には必須
Python Pythonを書く時には必須
Pylance Pythonを書く時には必須
Ruff Pythonのlinter
json jsonファイルを編集するときに便利
indent-rainbow Pythonのプログラムを書いていると便利
Rainbow CSV CSVファイルを見るときに便利
Hex Editor Binaryファイルを見るときに便利

キーショートカット

コマンドパレット(Ctrl+Shift+P)を開いて、Preferences: Open Keyboard Shortcutsを開くきます。 下記の機能を検索して、ダブルクリックしたうえでShortcut Keyを登録します。

機能 Shortcut Key
View: Toggle Maximized Panel Ctrl + Shift + j

フォント

Source Han Code JPを利用しているので、ダウンロードしてインストールを実施します。

下記のGitHubに詳細が記載されています。

公式GitHub: https://github.com/adobe-fonts/source-han-code-jp?tab=readme-ov-file

Source Han Code JPとは、日本語にも対応したコーディング向けのフォントです。 Adobe社が開発したフォントの「Source Code Pro」と「Source Han Sans JP(源ノ角ゴシック JP)」を組み合わせたものです。

Windowsへのダウンロード方法

  1. zipファイルをgithubのReleseページからzipファイルをダウンロードします。 Release
  2. 解凍して、OTFフォルダ内のすべてのファイルを選択します。
  3. 右クリックして、「インストール」ボタンをクリック

設定ファイル(settings.json)

上記の拡張機能を入れたうえで、最終的に下記の設定ファイルです。

{
    "editor.fontFamily": "'Source Han Code JP', Consolas, 'Courier New', monospace",
    "editor.mouseWheelZoom": true,

    "workbench.iconTheme": "material-icon-theme",
    "workbench.colorTheme": "Monokai",

    // markdown settings

    // --- Markdown拡張機能(markdownlint)の設定 ---
    "markdownlint.config": {
        "MD013": false,    // 1行の長さ制限を無効化(日本語だと厳しすぎるため)
        "MD033": false,    // HTML記述を許可
        "MD041": false     // 第1行が必ずしもh1でなくてもOKにする
    },
    "[markdown]": {
        "editor.tabSize": 2,
        "editor.insertSpaces": true,  
        "editor.wordWrap": "on",      
        "editor.formatOnSave": true,
        "editor.formatOnPaste": true,
        "editor.defaultFormatter": "DavidAnson.vscode-markdownlint"
    },

    "[python]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.fixAll": "explicit",
            "source.organizeImports": "explicit"
        },
        "editor.defaultFormatter": "charliermarsh.ruff"
    },

    "terminal.integrated.defaultProfile.windows": "Git Bash",
    "terminal.integrated.profiles.windows": {
        "Git Bash": {
            "path": "C:\\Program Files\\Git\\bin\\bash.exe"
        }
    }

}