Skip to content

Commit

Permalink
Fix caret move (swap shift/non-shift)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rcmdnk committed Sep 16, 2022
1 parent 058e183 commit 9513461
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
9 changes: 5 additions & 4 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions lib/vim_move.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -26,15 +26,15 @@
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()
}
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()
}
Expand Down Expand Up @@ -69,7 +69,7 @@
send {Ctrl Up}
}

Home(){
Zero(){
if WinActive("ahk_group VimDoubleHomeGroup"){
Send, {Home}
}
Expand Down Expand Up @@ -124,7 +124,7 @@
}
; Home/End
}else if(key == "0"){
this.Home()
this.Zero()
}else if(key == "$"){
if(this.shift == 1){
Send, +{End}
Expand All @@ -133,21 +133,21 @@
}
}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}
Send, +^{Left}
}else{
Send, +{Home}
}
}else{
if WinActive("ahk_group VimCaretMove"){
Send, {Home}
Send, ^{Right}
Send, ^{Left}
}else{
Send, {Home}
}
}
; Words
}else if(key == "w"){
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9513461

Please sign in to comment.