個人的なメモ帳

個人的なメモを書いていきます。

Visual Studio Codeの個人的な設定

概要

Visual Studio Code使っていると、ちょくちょく設定変えたくなったところがあったのでメモ

MarkdownのTabがデフォルトではスペース4個なので、スペース2個に

  1. Ctrl-Shift-P押して「Open Setting」と入力したら出てくる「Preferences: Open Settings (JSON)」を選択
  2. settings.jsonが開くので、以下を追記
"[markdown]": {
    "editor.tabSize": 2,
},

参考:追記前から追記後はこんな感じ

変更前

{
    "window.zoomLevel": 3,
    "git.autofetch": true,
    "explorer.confirmDragAndDrop": false
}


変更後

{
    "window.zoomLevel": 3,
    "[markdown]": {
        "editor.tabSize": 2,
    },
    "git.autofetch": true,
    "explorer.confirmDragAndDrop": false
}

キーボードショートカットの挙動を変更(vimプラグイン入れている場合)

 Windowsの時にvimプラグイン入れていると、ショートカットがvimプラグイン側に取られるので、一部変更する。(MacだとCmdとCtrlが別れているのであまり気にならない。)
 vimゆるふわ勢なので、もう少しvimのショートカット活用するようになったら変えるかも

  1. Ctrl-Shift-P押して「Open Keyboard」と入力したら出てくる「Preferences: Open Keyboard Shortcuts (JSON)」を選択
  2. keybindings.jsonが開くので、以下を追記
{ "key": "ctrl+f",  "command": "actions.find",
                        "when": "editorTextFocus && !inDebugRepl" },
{ "key": "ctrl+a",  "command": "editor.action.selectAll",
                        "when": "editorTextFocus && !inDebugRepl" },
{ "key": "ctrl+c",   "command": "editor.action.clipboardCopyAction",
                        "when": "editorTextFocus && !inDebugRepl" },
{ "key": "ctrl+n",  "command": "workbench.action.files.newUntitledFile",
                        "when": "editorTextFocus && !inDebugRepl" },
{ "key": "ctrl+v",  "command": "editor.action.clipboardPasteAction",
                        "when": "editorTextFocus && !inDebugRepl && vim.mode == 'Insert'" },
{ "key": "ctrl+w",  "command": "workbench.action.closeActiveEditor",
                        "when": "editorTextFocus && !inDebugRepl" },
{ "key": "ctrl+x",  "command": "editor.action.clipboardCutAction",
                        "when": "editorTextFocus && !inDebugRepl" }

設定項目

ショートカット 挙動
ctrl+f 検索
ctrl+a 全選択
ctrl+c コピー
ctrl+n 新規ファイル
ctrl+v vimがInsertモードのときのみ貼り付け
(NormalモードではVisualモードとして使用したいので)
ctrl+w タブを閉じる
ctrl+x 切り取り

参考:追記前から追記後はこんな感じ

変更前

// Place your key bindings in this file to override the defaults
[
]


変更後

// Place your key bindings in this file to override the defaults
[
    { "key": "ctrl+f",  "command": "actions.find",
                           "when": "editorTextFocus && !inDebugRepl" },
    { "key": "ctrl+a",  "command": "editor.action.selectAll",
                           "when": "editorTextFocus && !inDebugRepl" },
    { "key": "ctrl+c",   "command": "editor.action.clipboardCopyAction",
                           "when": "editorTextFocus && !inDebugRepl" },
    { "key": "ctrl+n",  "command": "workbench.action.files.newUntitledFile",
                           "when": "editorTextFocus && !inDebugRepl" },
    { "key": "ctrl+v",  "command": "editor.action.clipboardPasteAction",
                           "when": "editorTextFocus && !inDebugRepl && vim.mode == 'Insert'" },
    { "key": "ctrl+w",  "command": "workbench.action.closeActiveEditor",
                           "when": "editorTextFocus && !inDebugRepl" },
    { "key": "ctrl+x",  "command": "editor.action.clipboardCutAction",
                           "when": "editorTextFocus && !inDebugRepl" 
]