Skip to content

Commit

Permalink
feat: add new keybindings for Space and Enter in vim_move.ahk (#90)
Browse files Browse the repository at this point in the history
feat: add VimNonEditor group to disable Enter mapping in the normal mode.
  • Loading branch information
rcmdnk committed Sep 13, 2023
1 parent a7a70ab commit 0126253
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ If using a custom two-letter hotkey to enter the normal mode, the two letters mu
|Ctrl-u/Ctrl-d| Go Up/Down 10 line.|
|Ctrl-b/Ctrl-f| PageUp/PageDown.|
|gg/G| Go to the top/bottom of the file|
|Space| Right.|
|Enter| Move to the beginning of the next line.|

Note: Enter works only for editor applications (for other than Explorer, Q-dir, it works as Enter even in the normal mode).

In addition, `Repeat` is also available for some commands.

Expand Down
9 changes: 8 additions & 1 deletion lib/bind/vim_move.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@ b::Vim.Move.Repeat("b")
^f::Vim.Move.Repeat("^f")
; G
+g::Vim.Move.Move("+g")

; Space
Space::Vim.Move.Repeat("l")
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_")) and not WinActive("ahk_group VimNonEditor")
; Enter
Enter::
Vim.Move.Repeat("j")
Vim.Move.Move("^")
Return
#If
3 changes: 0 additions & 3 deletions lib/bind/vim_normal.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ Return
Vim.State.SetMode("Vim_Normal")
Return

#If Vim.IsVimGroup() and (Vim.State.IsCurrentVimMode("Vim_Normal"))
Space::Send, {Right}

; period
.::Send, +^{Right}{BS}^v

Expand Down
6 changes: 6 additions & 0 deletions lib/vim_ahk.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ class VimAhk{

DefaultGroup := this.SetDefaultActiveWindows()

; On following applications, Enter works as Enter at the normal mode.
GroupAdd, VimNonEditor, ahk_exe explorer.exe ; Explorer
GroupAdd, VimNonEditor, ahk_exe Explorer.exe ; Explorer, Explorer became also upper case, but lower case works for this
GroupAdd, VimNonEditor, ahk_exe Q-Dir_x64.exe ; Q-dir
GroupAdd, VimNonEditor, ahk_exe Q-Dir.exe ; Q-dir

; Following applications select the line break at Shift + End.
GroupAdd, VimLBSelectGroup, ahk_exe POWERPNT.exe ; PowerPoint
GroupAdd, VimLBSelectGroup, ahk_exe WINWORD.exe ; Word
Expand Down

0 comments on commit 0126253

Please sign in to comment.