> ![[moving_cli.png]]
> via. https://clementc.github.io/blog/2018/01/25/moving_cli/
上記のキーバインドを覚えると、一気にキーボードでの操作が楽になる。
macOS標準 (Cocoa標準のテキストフィールド) で `ctrl+` のキーバインドはできるが、`alt+` の移動 (と `ctrl+w`) ができなかったので設定を行った。
`~/Library/KeyBindings/DefaultKeyBinding.dict` にファイルを設置したいが何も準備されていない。
`KeyBindings` のディレクトリから作成する必要がある。
```
mkdir -p ~/Library/KeyBindings
```
次にファイルを新規作成する。
`vi ~/Library/KeyBindings/DefaultKeyBinding.dict`
```dict
{
"~d" = "deleteWordForward:";
"^w" = "deleteWordBackward:";
"~f" = "moveWordForward:";
"~b" = "moveWordBackward:";
}
```
上記ファイルを新規作成してmacを再起動すれば、(`alt+` 他) のキーが効くようになる。
設定: [⌨️ \[DefaultKeyBinding.dict\] macOSキーバインディング設定を追加 · usagizmo/dotfiles@ef9e402 · GitHub](https://github.com/usagizmo/dotfiles/commit/ef9e402b3763e4a7f234beaac208f14eeb93636e)
各種ターミナルでは `alt+` のキーが効かないので、別途設定が必要になる。
- [macでシェルのメタキー(option alt)を有効化する方法を各種ターミナルまとめ #Mac - Qiita](https://qiita.com/apollo_program/items/a3a7644ee077c7bf3cd2)
ref.
- [Mac OS X: Emacs-like keybindings everywhere - sensible.io Blog](https://blog.sensible.io/2012/10/19/mac-os-x-emacs-style-keybindings-everywhere.html)
- [DefaultKeyBinding.dictを使って、macOSのキーバインドを変更 #Mac - Qiita](https://qiita.com/See_Ku/items/4bd8cfc6a7c4266f9bb6)
- [テキスト編集のキー操作を自在にコントロールする - ザリガニが見ていた...。](https://zariganitosh.hatenablog.jp/entry/20101026/text_key_binding)
- [GitHub - omonomo/DefaultKeyBinding: DefaultKeyBinding.dict サンプル](https://github.com/omonomo/DefaultKeyBinding)
- [【Mac入門】Emacsキーバインド\|絶対使ってほしいショートカットで仕事効率を上げる - YouTube](https://www.youtube.com/watch?v=rzRMpVoa6MM)