diff --git a/README.md b/README.md index 4135a82e..04617f81 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ All of these can be changed from setting menu, too. |:-----|:----------|:------| |VimRestoreIME|If 1, IME status is restored at entering insert mode.|1| |VimJJ|If 1, `jj` changes mode to Normal from Insert.|0| -|VimLongEscNormal|If 1, pushing escape sends escape to the underlying application, while holding escape sets normal mode.|0| +|VimLongEscNormal|If 1, pushing escape/Ctrl-[ sends escape to the underlying application, while holding escape sets normal mode.|0| |VimTwoLetterEsc|A list of character pairs to press together during insert mode to get to normal mode. For example, a value of `jf` means pressing `j` and `f` at the same time will enter normal mode.|""| |VimDisableUnused|Disable level of unused keys in normal mode (see below for details).|3| |VimSetTitleMatchMode|SetTitleMatchMode: 1: Start with, 2: Contain, 3: Exact match|2| @@ -191,7 +191,7 @@ Here are the main modes. |Visual Mode|There are three visual mode: Character-wise, Line-wise, and Block-wise. Block-wise visual mode is valid only for applications which support block-wise selection (such TeraPad).| |Command Mode|Can be used for saving file/quitting.| -The initial state is `Insert Mode`, then `Esc` or `Ctrl-[` brings you to Normal Mode. +The initial state is `Insert Mode`, then `ESC` or `Ctrl-[` brings you to Normal Mode. In Normal Mode, `i` is the key to be back to Insert Mode. @@ -212,6 +212,11 @@ ESC/Ctrl-[ switch off IME if IME is on. ESC acts as ESC when IME is on and converting instructions. Ctrl-[ switches off IME and enters Normal Mode even if IME is on. +Long press ESC/Ctrl-[ will send these original keys, if `VimLongEscNormal` is not enabled (0). +If `VimLongEscNormal` is enabled, +short press these keys will send these original +and long press these keys will change the mode to the normal mode. + If using a custom two-letter hotkey to enter normal mode, the two letters must be different. ## Available commands in Normal Mode diff --git a/lib/bind/vim_enter_normal.ahk b/lib/bind/vim_enter_normal.ahk index 3741ddf3..27e8a114 100644 --- a/lib/bind/vim_enter_normal.ahk +++ b/lib/bind/vim_enter_normal.ahk @@ -1,6 +1,6 @@ #If WinActive("ahk_group " . Vim.GroupName) Esc::Vim.State.HandleEsc() -^[::Vim.State.SetNormal() +^[::Vim.State.HandleCtrlBracket() #If WinActive("ahk_group " . Vim.GroupName) and (Vim.State.StrIsInCurrentVimMode( "Insert")) and (Vim.Conf["VimJJ"]["val"] == 1) ~j up:: ; jj: go to Normal mode. diff --git a/lib/vim_ahk.ahk b/lib/vim_ahk.ahk index aa1c097a..9e0b986f 100644 --- a/lib/vim_ahk.ahk +++ b/lib/vim_ahk.ahk @@ -19,8 +19,8 @@ class VimAhk{ __About(){ - this.About.Version := "v0.8.0" - this.About.Date := "15/Oct/2020" + this.About.Version := "v0.8.1" + this.About.Date := "17/Oct/2020" this.About.Author := "rcmdnk" this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows." this.About.Homepage := "https://github.com/rcmdnk/vim_ahk" @@ -227,8 +227,4 @@ class VimAhk{ } Return DefaultGroup } - - AddToTwoLetterMap(l1, l2){ - this.Conf["VimTwoLetter"]["val"] := this.Conf["VimTwoLetter"]["val"] . this.GroupDel . l1 . l2 - } } diff --git a/lib/vim_state.ahk b/lib/vim_state.ahk index 9b1f33ef..4abcf4bf 100644 --- a/lib/vim_state.ahk +++ b/lib/vim_state.ahk @@ -103,6 +103,23 @@ } } + HandleCtrlBracket(){ + KeyWait, [, T0.5 + LongPress := ErrorLevel + global Vim, VimLongEscNormal + both := VimLongEscNormal && LongPress + neither := !(VimLongEscNormal || LongPress) + SetNormal := both or neither + if (SetNormal) { + Vim.State.SetNormal() + } else { + Send, ^[ + } + if (LongPress){ + KeyWait, [ + } + } + IsCurrentVimMode(mode){ this.CheckValidMode(mode) Return (mode == this.Mode)