学習バンザイITエンジニアの精神安穏日記

ITエンジニアというより、IT系雑務者

vsCodeVim新しくファイルを開いても現在開いているファイルに上書きされない現象の対処方法

2024-08-01以下のプロセス不要になっているっぽい?

元issue

https://github.com/VSCodeVim/Vim/issues/4559

参考にした解決方法

stackoverflow.com

ありがとう

設定解説

(2) The macro approach:

stack overflowの解決法の2番目のアプローチをとる。

1. multi-commandという拡張機能をインストールする

marketplace.visualstudio.com

2. settings.jsonに下記を設定する

「ユーザー設定を開く(JSON)」で、以下の設定をする。

この設定をしただけでは、ただコマンドが登録されるだけなので注意。

commandには定義名を書く。

  "multiCommand.commands": [
    {
      "command": "multiCommand.openFileInActiveEditor",
      "sequence": [
        "workbench.action.acceptSelectedQuickOpenItem",
        "workbench.action.previousEditor",
        "workbench.action.closeActiveEditor",
        "workbench.action.closeQuickOpen"
      ]
    }
  ],

sequenceに実行する順番にアクションを書く。

  1. workbench.action.acceptSelectedQuickOpenItem
  2. Ctrl+Pやファイル検索で選択されたファイルなどを開く。
  3. workbench.action.previousEditor
  4. 前のエディタに切り替える。複数のエディタを開いている場合に、前に表示していたエディタに戻る。
  5. workbench.action.closeActiveEditor
  6. 現在アクティブなエディタを閉じる
  7. workbench.action.closeQuickOpen
  8. 1で開いたポップアップを閉じる

3. keybinding.jsonの設定

「キーボードショートカットを開く(JSON)」で以下の設定をする。

z ```json

{ "key": "cmd+n", "command": "extension.multiCommand.execute", "args": { "command": "multiCommand.openFileInActiveEditor" }, "when": "inFilesPicker && inQuickOpen" },