Open16

VS Code Neovimを試す

ピン留めされたアイテム
AyuuAyuu

随時更新してます🧰

AyuuAyuu

nvimのパスをsettings.jsonに追記する

settings.json
"vscode-neovim.neovimExecutablePaths.darwin": "/opt/homebrew/bin/nvim",
AyuuAyuu

パフォーマンス向上のために別ホストで動かす...??設定

setting.json
 "extensions.experimental.affinity": {
    "asvetliakov.vscode-neovim": 1
 }
AyuuAyuu

Insertモード時はVSCodeが,それ以外はNeovim管轄らしい
なのでjj等は使えない.
使いたいならvscodeの設定で変えないといけないっぽい

AyuuAyuu

Insertモード時以外にスペースキー2回押しでクイックオープン開くようにした
VSCodeはプレビューが見れないのが残念

keybindings.json
[
  {
    "key": "space space",
    "command": "workbench.action.quickOpen",
    "when": "neovim.init && neovim.mode != 'insert'"
  }
]
AyuuAyuu

クイックオープンの選択肢をctrl + j,ctrl + kで選択できるようにした
ctrl + n, ctrl + pは押しづらいし,何より使用頻度が高い

keybindings.json
  {
    "key": "ctrl+j",
    "command": "workbench.action.quickOpenSelectNext",
    "when": "inQuickOpen && neovim.wildMenuVisible || inQuickOpen && neovim.mode != 'cmdline'"
  },
  {
    "key": "ctrl+n",
    "command": "-workbench.action.quickOpenSelectNext",
    "when": "inQuickOpen && neovim.wildMenuVisible || inQuickOpen && neovim.mode != 'cmdline'"
  },
  {
    "key": "ctrl+k",
    "command": "workbench.action.quickOpenSelectPrevious",
    "when": "inQuickOpen && neovim.wildMenuVisible || inQuickOpen && neovim.mode != 'cmdline'"
  },
  {
    "key": "ctrl+p",
    "command": "-workbench.action.quickOpenSelectPrevious",
    "when": "inQuickOpen && neovim.wildMenuVisible || inQuickOpen && neovim.mode != 'cmdline'"
AyuuAyuu

shift + h,shift + lで行頭,行末にnormalモードのまま移動できるようにした
デフォルトは^,$,押しづらいったら.
argsで渡してあげると渡したキーの動作に上書きできるみたい

keybindings.json
  {
    "key": "shift+h",
    "command": "vscode-neovim.send",
    "when": "neovim.init && neovim.recording || editorTextFocus && neovim.init && neovim.mode != 'insert' && editorLangId not in 'neovim.editorLangIdExclusions'",
    "args": "^"
  },
  {
    "key": "home",
    "command": "-vscode-neovim.send",
    "when": "neovim.init && neovim.recording || editorTextFocus && neovim.init && neovim.mode != 'insert' && editorLangId not in 'neovim.editorLangIdExclusions'"
  },
  {
    "key": "shift+l",
    "command": "vscode-neovim.send",
    "when": "neovim.init && neovim.recording || editorTextFocus && neovim.init && neovim.mode != 'insert' && editorLangId not in 'neovim.editorLangIdExclusions'",
    "args": "$"
  },
  {
    "key": "end",
    "command": "-vscode-neovim.send",
    "when": "neovim.init && neovim.recording || editorTextFocus && neovim.init && neovim.mode != 'insert' && editorLangId not in 'neovim.editorLangIdExclusions'"
  }
AyuuAyuu

ctrl + h, ctrl + lでタブを移動できるようにした.
数値指定で移動するのが一番早いんだろうけど数えるのめんどくさい.

keybindings.json
  {
    "key": "shift+cmd+]",
    "command": "-workbench.action.nextEditor"
  },
  {
    "key": "ctrl+l",
    "command": "workbench.action.nextEditor"
  },
  {
    "key": "shift+cmd+[",
    "command": "-workbench.action.previousEditor"
  },
  {
    "key": "ctrl+h",
    "command": "workbench.action.previousEditor"
  }
AyuuAyuu

ショートカット一覧見てたら試験段階のクイック検索なるものがあったのでctrl+/で起動できるようにしてみた.フローティングウインドウでプレビュー見れたら最高なんだけどなぁ...

あとcmd+shift+fの全文検索の結果をctrl+jctrl+kで選択できるようにした.
デフォルトのコマンドだと検索タブにいなくてもhasSearchResultに引っかかってしまってうまくいかなかったのでその条件を外した

keybindings.json
  {
    "key": "ctrl+/",
    "command": "workbench.action.experimental.quickTextSearch"
  },
  {
    "key": "f4",
    "command": "-search.action.focusNextSearchResult",
    "when": "hasSearchResult || inSearchEditor"
  },
  {
    "key": "ctrl+j",
    "command": "search.action.focusNextSearchResult",
    "when": "inSearchEditor"
  },
  {
    "key": "shift+f4",
    "command": "-search.action.focusPreviousSearchResult",
    "when": "hasSearchResult || inSearchEditor"
  },
  {
    "key": "ctrl+k",
    "command": "search.action.focusPreviousSearchResult",
    "when": "inSearchEditor"
  }
AyuuAyuu

MTG中などコードを共有する時にGithub上のリンクをコピーしたい時がある(パーマリンク?っていうらしい
https://docs.github.com/ja/repositories/working-with-files/using-files/getting-permanent-links-to-files

shift+cmd+cで現在のカーソル行を指定したリンクを,ctrl+shift+cmd+cで現在のファイルを指定したリンクをクリップボードにコピーするようにした

keybindings.json
  {
    "key": "shift+cmd+c" ,
    "command": "gitlens.copyRemoteFileUrlToClipboard"
  },
  {
    "key": "ctrl+shift+cmd+c",
    "command": "gitlens.copyRemoteFileUrlWithoutRange"
  }
AyuuAyuu

ファイルやフォルダーの新規作成がaだったりshift + aだったりとなんかしっくりこなかったので新規ファイルをcmd + nに,新規フォルダをcmd + ctrl + nに割り当てた.
しっくりきた

keybindings.json
  {
    "key": "ctrl+cmd+n",
    "command": "explorer.newFolder",
    "when": "filesExplorerFocus && !inputFocus"
  },
  {
    "key": "shift+a",
    "command": "-explorer.newFolder",
    "when": "filesExplorerFocus && !inputFocus"
  },
  {
    "key": "cmd+n",
    "command": "explorer.newFile",
    "when": "filesExplorerFocus && !inputFocus"
  },
  {
    "key": "a",
    "command": "-explorer.newFile",
    "when": "filesExplorerFocus && !inputFocus"
  },
  {
    "key": "cmd+n",
    "command": "-workbench.action.files.newUntitledFile"
  }
AyuuAyuu

パーマリンクだけじゃなく普通のファイルパスもよくコピーすることに気がついたので追加していく.
二段階のショートカットにしてパーマリンクと一緒に覚えやすくしたつもり.
この変更によってパーマリンクのショートカットも変更した.

  • 相対パスのコピー
    • cmd+shift+c + c
  • 絶対パスのコピー
    • ctrl+cmd+shift+c + c
  • パーマリンクのコピー(行指定)
    • cmd+shift+c + r
  • パーマリンクのコピー(ファイル全体)
    • ctrl+cmd+shift+c + r

ややこしいのでリンクコピー系のものを一度まとめて書いておく

keybinding.json
  {
    "key": "shift+cmd+c",
    "command": "-workbench.action.terminal.openNativeConsole",
    "when": "!terminalFocus"
  },
  {
    "key": "shift+cmd+c r",
    "command": "gitlens.copyRemoteFileUrlToClipboard"
  },
  {
    "key": "ctrl+shift+cmd+c r",
    "command": "gitlens.copyRemoteFileUrlWithoutRange"
  },
  {
    "key": "shift+alt+cmd+c",
    "command": "-copyRelativeFilePath",
    "when": "!editorFocus"
  },
  {
    "key": "cmd+k shift+alt+cmd+c",
    "command": "-copyRelativeFilePath",
    "when": "editorFocus"
  },
  {
    "key": "shift+cmd+c c",
    "command": "copyRelativeFilePath"
  },
  {
    "key": "alt+cmd+c",
    "command": "-copyFilePath",
    "when": "!editorFocus"
  },
  {
    "key": "cmd+k alt+cmd+c",
    "command": "-copyFilePath",
    "when": "editorFocus"
  },
  {
    "key": "ctrl+shift+cmd+c c",
    "command": "copyFilePath"
  },
  {
    "key": "ctrl+cmd+n",
    "command": "explorer.newFolder",
    "when": "filesExplorerFocus && !inputFocus"
  },