From 95134612f2d84e287f37de0e58b30a80e292d070 Mon Sep 17 00:00:00 2001 From: rcmdnk Date: Fri, 16 Sep 2022 10:41:44 +0900 Subject: [PATCH] Fix caret move (swap shift/non-shift) rename Home()->Zero() (it is to move at the real first charecter of the line, instead of non-space first character) Remove NotePad from VimCaretMove, it does not work at Windows 11 --- lib/vim_ahk.ahk | 9 +++++---- lib/vim_move.ahk | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/vim_ahk.ahk b/lib/vim_ahk.ahk index 0b558225..82189518 100644 --- a/lib/vim_ahk.ahk +++ b/lib/vim_ahk.ahk @@ -20,8 +20,8 @@ class VimAhk{ __About(){ - this.About.Version := "v0.11.3" - this.About.Date := "14/Feb/2022" + this.About.Version := "v0.11.5" + this.About.Date := "16/Sep/2022" this.About.Author := "rcmdnk" this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows." this.About.Homepage := "https://github.com/rcmdnk/vim_ahk" @@ -66,8 +66,9 @@ class VimAhk{ GroupAdd, VimDoubleHomeGroup, ahk_exe Code.exe ; Visual Studio Code ; Followings can emulate ^. For others, ^ works as same as 0 - GroupAdd, VimCaretMove, ahk_exe notepad.exe ; NotePad - GroupAdd, VimCaretMove, ahk_exe Notepad.exe ; NotePad + ; It does not work for NotePad at Windows 11 + ; GroupAdd, VimCaretMove, ahk_exe notepad.exe ; NotePad + ; GroupAdd, VimCaretMove, ahk_exe Notepad.exe ; NotePad ; Followings start cursor from the same place after selection. ; Others start right/left (by cursor) point of the selection diff --git a/lib/vim_move.ahk b/lib/vim_move.ahk index 61b2b079..c1712a30 100644 --- a/lib/vim_move.ahk +++ b/lib/vim_move.ahk @@ -13,7 +13,7 @@ if(this.Vim.State.IsCurrentVimMode("Vim_VisualLineFirst")) and (key == "k" or key == "^u" or key == "^b" or key == "g"){ Send, {Shift Up}{End} - this.Home() + this.Zero() Send, {Shift Down} this.Up() this.vim.state.setmode("Vim_VisualLine") @@ -26,7 +26,7 @@ if(this.Vim.State.StrIsInCurrentVimMode("Vim_ydc")) and (key == "k" or key == "^u" or key == "^b" or key == "g"){ this.Vim.State.LineCopy := 1 Send,{Shift Up} - this.Home() + this.Zero() this.Down() Send, {Shift Down} this.Up() @@ -34,7 +34,7 @@ if(this.Vim.State.StrIsInCurrentVimMode("Vim_ydc")) and (key == "j" or key == "^d" or key == "^f" or key == "+g"){ this.Vim.State.LineCopy := 1 Send,{Shift Up} - this.Home() + this.Zero() Send, {Shift Down} this.Down() } @@ -69,7 +69,7 @@ send {Ctrl Up} } - Home(){ + Zero(){ if WinActive("ahk_group VimDoubleHomeGroup"){ Send, {Home} } @@ -124,7 +124,7 @@ } ; Home/End }else if(key == "0"){ - this.Home() + this.Zero() }else if(key == "$"){ if(this.shift == 1){ Send, +{End} @@ -133,14 +133,6 @@ } }else if(key == "^"){ if(this.shift == 1){ - if WinActive("ahk_group VimCaretMove"){ - this.Home() - Send, ^{Right} - Send, ^{Left} - }else{ - this.Home() - } - }else{ if WinActive("ahk_group VimCaretMove"){ Send, +{Home} Send, +^{Right} @@ -148,6 +140,14 @@ }else{ Send, +{Home} } + }else{ + if WinActive("ahk_group VimCaretMove"){ + Send, {Home} + Send, ^{Right} + Send, ^{Left} + }else{ + Send, {Home} + } } ; Words }else if(key == "w"){ @@ -209,7 +209,7 @@ YDCMove(){ this.Vim.State.LineCopy := 1 - this.Home() + this.Zero() Send, {Shift Down} if(this.Vim.State.n == 0){ this.Vim.State.n := 1