5
8

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 1 year has passed since last update.

VimmerのためのVScodeを120%活かすキーバインド[暫定]

Last updated at Posted at 2020-01-23

#はじめに
こちらを参考にしました

VScodeにまつわるおすすめ設定には様々なものがありますが、私のようなVimmerはVscodeのキーバインドなど覚えたくないのです。この記事を見てくれているということは、あなたもきっと同じ心境なのでしょう。

やりたいことは極力マウスを使わずにvscodeのキーバインドはいじらずvscodevimを120%活かす方法です。

参考

こちらを読んでいただけると良いと思います!

#方法
ToggleとFocusの2つだけに焦点をあてます。

##Toggle
これはONOFFにする機能です。たとえばサイドバーを開いたり閉じたりするような機能のことをいいます。

そして使用するToggleがサイドバーとターミナルで両方ともデフォルトの設定が存在します。

Toggle
  // --------------------------------------
  // Toggle
  // --------------------------------------

  // サイドバーのtoggle
  {
    "key": "ctrl+b",
    "command": "workbench.action.toggleSidebarVisibility"
  },

  // ターミナルのtoggle
  {
    "key": "ctrl+`",
    "command": "workbench.action.terminal.toggleTerminal"
  },

Focus

これはタブやサイドバーなどあれこれ開くことができますが、それらをアクティブな状態にし操作できるようにする機能です。

そして使用するFocusはエスクプローラーとターミナルとエディターです。こちらは設定する必要があります。

Focus
  // --------------------------------------
  // Focus
  // --------------------------------------

  // エクスプローラーへフォーカス
  { "key": "ctrl+h", "command": "workbench.files.action.focusOpenEditorsView" },

  // ターミナルへフォーカス
  { "key": "ctrl+j", "command": "workbench.action.terminal.focus" },

  // エディターへフォーカス
  {
    "key": "ctrl+k",
    "command": "workbench.action.focusActiveEditorGroup"
  },

おまけ

vimのバインドを1つ無効化

サイドバーのtoggleと被るので無効化する。

  // --------------------------------------
  // 無効
  // --------------------------------------
  {
    "key": "ctrl+b",
    "command": "-extension.vim_ctrl+b",
    "when": "editorTextFocus && vim.active && vim.use<C-b> && !inDebugRepl && vim.mode != 'Insert'"
  },

まとめ

[
  // --------------------------------------
  // 無効
  // --------------------------------------
  {
    "key": "ctrl+b",
    "command": "-extension.vim_ctrl+b",
    "when": "editorTextFocus && vim.active && vim.use<C-b> && !inDebugRepl && vim.mode != 'Insert'"
  },


  // --------------------------------------
  // 有効
  // --------------------------------------


  // --------------------------------------
  // TOGGLE
  // --------------------------------------

  // サイドバーのtoggle
  {
    "key": "ctrl+b",
    "command": "workbench.action.toggleSidebarVisibility"
  },

  // ターミナルのtoggle
  {
    "key": "ctrl+`",
    "command": "workbench.action.terminal.toggleTerminal"
  },


  // --------------------------------------
  // FOCUS
  // --------------------------------------

  // エクスプローラーへフォーカス
  { "key": "ctrl+h", "command": "workbench.files.action.focusFilesExplorer"},

  // ターミナルへフォーカス
  { "key": "ctrl+j", "command": "workbench.action.terminal.focus" },

  // エディターへフォーカス
  {
    "key": "ctrl+k",
    "command": "workbench.action.focusActiveEditorGroup"
  },


  // --------------------------------------
  // エクスプローラー
  // --------------------------------------

  // ファイルを開く
  {
    "key": "o",
    "command": "list.select",
    "when": "explorerViewletFocus && listFocus &&explorerViewletVisible && !inputFocus"
  },
  // ファイルを削除
  {
    "key": "d",
    "command": "deleteFile",
   "when": "explorerViewletFocus && listFocus &&explorerViewletVisible && !inputFocus"
  }, 
  // ファイル名を変更
  {
    "key": "n",
    "command": "renameFile",
    "when": "explorerViewletFocus && listFocus &&explorerViewletVisible && !inputFocus"
  },
  // Reflesh
  {
    "key": "r",
    "command": "workbench.files.action.refreshFilesExplorer",
    "when": "explorerViewletFocus && listFocus &&explorerViewletVisible && !inputFocus",
  },


  // --------------------------------------
  // 設定ファイル
  // --------------------------------------

  // keyboard shortcuts を開く
  {
    "key": "ctrl+shift+/",
    "command": "workbench.action.openGlobalKeybindings"
  },
  // keybindings.json を開く
  {
    "key": "ctrl+shift+k",
    "command": "workbench.action.openGlobalKeybindingsFile"
  },
  // settings.json を開く
  {
    "key": "ctrl+shift+s",
    "command": "workbench.action.openSettingsJson"
  },
]
5
8
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
5
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?