10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

iTerm2 + Vim (MacVim-Kaoriya) + im_control で日本語入力固定モード

Last updated at Posted at 2013-10-23

いつも iTerm2 で MacVim-Kaoriya 内の Vim を使って作業をしているが、<C-^> での IM 切替が出来ない関係で im_control の日本語入力固定モードが使えていなかった。
IMCtrl を設定することで、何とか動いたのでメモ(.gvimrc での noimdisableactivate 設定は割愛)

.vimrc
if has('mac')
  if has('gui_running')
    let IM_CtrlMode = 4
  else
    let IM_CtrlMode = 1

    function! IMCtrl(cmd)
      let cmd = a:cmd
      if cmd == 'On'
        let res = system('osascript -e "tell application \"System Events\" to keystroke (key code {104})" > /dev/null 2>&1')
      elseif cmd == 'Off'
        let res = system('osascript -e "tell application \"System Events\" to keystroke (key code {102})" > /dev/null 2>&1')
      elseif cmd == 'Toggle'
        let res = system('osascript -e "tell application \"System Events\" to keystroke (key code {55, 49})" > /dev/null 2>&1')
      endif
      return ''
    endfunction
  endif

  " 「日本語入力固定モード」のMacVimKaoriya対策を無効化
  let IM_CtrlMacVimKaoriya = 0
  " ctrl+jで日本語入力固定モードをOnOff
  inoremap <silent> <C-j> <C-^><C-r>=IMState('FixMode')<CR>
endif

AppleScript を使って切り替えを行っている。他に良い方法ありそうだけど良く分からない。

10
11
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
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?