Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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

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 を使って切り替えを行っている。他に良い方法ありそうだけど良く分からない。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした