1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

vscodeでemacsのキーバインドを設定してみた

1
Posted at

vscodeでemacsのキーバインドを設定してみた

はじめに

emacsを使っていた人で、vscodeに移行した人はいませんか?
vscodeを使いながらemacsのキーバインドを使う方法
を見つけたので、備忘録を兼ねて紹介します。

対象者

vscodeを使っている人でemacsとdiredのキーバインドが使いたい人
emacsの拡張機能を入れるとWindowsでよく使うショートカット(C-cなど)が使えなくなりますが、その対策も紹介します。

環境

項目 バージョン
OS Windows10
vscode 1.110.1

設定方法

いくつかの拡張機能を試してみて、以下の機能に落ち着きました。

  • Emacs Friendly Keymap
  • vscode dired

サポートされるemacsとdiredのキーバインド

Emacs Friendly Keymap

オペレーション キーバインド
ファイルを保存 C-x C-s
ファイルを別名で保存 C-x C-w
バッファを閉じる C-x k
ウィンドウの操作 C-x n (n:0~3)
インクリメンタル検索(前方) C-s
インクリメンタル検索(後方) C-r
コマンドを中断 C-g

vscode dired

オペレーション キーバインド
diredを開く C-x f
ファイルを開く Enter / f
上のディレクトリへ移動 ^
ファイルを削除マーク d
マークしたファイルを削除実行 x
ディレクトリを新規作成 +
バッファを更新 g

リネーム(R)とコピー(C)もできるようなのですが、実際はできませんでした。

Windowsショートカットの設定方法

以下の設定でC-a,C-x,C-c,C-vが使えるようになります

\Users<ユーザー名>\AppData\Roaming\Code\User\keybindings.json
に追加します。

  {
    "key": "ctrl+a",
    "command": "editor.action.selectAll",
    "when": "textInputFocus && !terminalFocus"
  },
    {
    "key": "ctrl+x",
    "command": "editor.action.clipboardCutAction",
    "when": "textInputFocus && !terminalFocus && editorHasSelection"
  },
  {
    "key": "ctrl+c",
    "command": "editor.action.clipboardCopyAction",
    "when": "textInputFocus && !terminalFocus"
  },
  {
    "key": "ctrl+v",
    "command": "editor.action.clipboardPasteAction",
    "when": "textInputFocus && !terminalFocus"
  }

まとめ

vscodeになって慣れていたemacsのキーマップが使えずにストレスがたまっていましたが、これで無事に解決しました。
C-c、C-vも使えるので快適です。
ただ、リネーム(R)とコピー(C)ができないのは地味に不便なのでヒマな時に調査してみます。

関連記事

henagineerのプログラミング・開発記事まとめ

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?