Skip to content

Instantly share code, notes, and snippets.

@rcmdnk
Last active February 19, 2020 02:10
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rcmdnk/6147672 to your computer and use it in GitHub Desktop.
Save rcmdnk/6147672 to your computer and use it in GitHub Desktop.
Automatic IME off for Vim by AutoHotkey. IME.ahk is needed to be placed in the same directory with this setting script (http://www6.atwiki.jp/eamat/pages/17.html).
; Auto execute section is the region before any return/hotkey
; For Terminal/Vim
GroupAdd Terminal, ahk_class PuTTY
GroupAdd Terminal, ahk_class mintty ; cygwin
GroupAdd TerminalVim, ahk_group Terminal
GroupAdd TerminalVim, ahk_class Vim
; Include IME.hak
; http://www6.atwiki.jp/eamat/pages/17.html
#Include %A_ScriptDir%IME.ahk
Return
; ESC + IME
#IfWInActive, ahk_group TerminalVim
Esc:: ; Just send Esc at converting.
if (IME_GET(A)) {
if (IME_GetConverting(A)) {
Send,{Esc}
} else {
IME_SET()
}
} else {
Send,{Esc}
}
Return
^[:: ; Go to Normal mode (for vim) with IME off even at converting.
if (IME_GET(A)) {
Send,{Esc}
Sleep 1 ; wait 1 ms (Need to stop converting)
IME_SET()
Send,{Esc}
} else {
Send,{Esc}
}
Return
#IfWInActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment