LoginSignup
2
5

More than 5 years have passed since last update.

vimでtabと<C-i>を使い分ける(mac)

Posted at

はじめに

キーボードのスキャンコードの仕様上、tab<C-i>は等価扱いのようです[^1]

Both the keys produce the same key scan code.

Ctrl-I      Tab
Ctrl-[      Esc
Ctrl-M      Enter
Ctrl-H      Backspace

上記より、vimでtabのキーバインドを登録したいけど
<C-i>(ジャンプリスト進む)が使えない、といった問題が発生します

Linuxでは下記の手法で分ける事ができるようです
http://qiita.com/norio13/items/9c05412796a7dea5cd91

macは上記のような解決法が中々見つかりませんでした

使い分け方法

  1. Karabiner[^2]を使って<C-i>F12等適当なキーに割り当てる

    private.xml
    <only>TERMINAL</only>
    <autogen>--KeyToKey-- KeyCode::I, ModifierFlag::CONTROL_L, KeyCode::F12</autogen>
    
  2. vimでF12<C-i>にする

    nnoremap <F12> <C-i>
    

これにより、tabのマッピングを変更しても<C-i>に影響が出なくなります
後はtabを好きにマッピングする

nnoremap <Tab> %

おわり

[^1]: http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_(Part_2)?action=edit&section=2
[^2]: https://pqrs.org/osx/karabiner/

2
5
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
2
5