Skip to content

Commit 7677a5e

Browse files
committed
Merge branch 'xxx'
2 parents b6a10a6 + 37d469f commit 7677a5e

File tree

5 files changed

+73
-47
lines changed

5 files changed

+73
-47
lines changed

README.md

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ vim.ahk is the setting file for [AutoHotkey](http://www.autohotkey.com/)(Autohot
77
vim.exe is a standalone application made from vim.ahk (available in [the releases page](https://github.com/rcmdnk/vim_ahk/releases)).
88

99
This is vim emulation for Windows.
10-
If you are interesting in same settings for Mac,
10+
If you are interested in the same settings for Mac,
1111
try Vim emulation for [Karabiner - Software for macOS](https://pqrs.org/osx/karabiner/): [Karabiner-Elements complex_modifications rules by rcmdnk](https://rcmdnk.com/KE-complex_modifications/).
1212

1313
## Installation
@@ -37,7 +37,7 @@ Unzip the zip file, and place the extracted vim_ahk folder where you like,
3737
then launch **vim_ahk.exe**.
3838

3939
:memo: place **vim_ahk_icons** folder in the same folder with **vim_ahk.exe**,
40-
otherwise the tray menu icon feature does not work.
40+
otherwise, the tray menu icon feature does not work.
4141

4242
### Build executable from the source
4343

@@ -66,7 +66,7 @@ The default setting enables vim-mode for the following applications:
6666
* OneNote
6767
* Applications using ahk_exe ApplicationFrameHost.exe
6868

69-
You can change them from the right click menu of task tray icon
69+
You can change them from the right-click menu of the task tray icon
7070
(find `VimMenu`-`Settings` in the list),
7171
or launch the setting window by `Ctrl-Alt-Shift-v`.
7272

@@ -79,7 +79,7 @@ Example line:
7979

8080
VimGroup := "ahk_exe chrome.exe,ahk_exe firefox.exe"
8181

82-
Multiple applications can be written by comma separated.
82+
Multiple applications can be written by a comma-separated.
8383

8484
Note: This will overwrite the default applications. If you want to **add**
8585
these applications to the default applications, add following applications
@@ -94,9 +94,9 @@ which makes matching methods as `Contain`.
9494

9595
If you set `OneNote`, all windows with a title containing `OneNote`
9696
(e.g. `XXX's OneNote`) will be included.
97-
If you set `VimSetTitleMatchMode` as 3, only exact title of `OneNote` will be included.
97+
If you set `VimSetTitleMatchMode` as 3, only the exact title of `OneNote` will be included.
9898

99-
Note: It may not work on OneNote. OneNote may has window name like
99+
Note: It may not work on OneNote. OneNote may have a window name like
100100
**User's Notebook - OneNote**, instead of **OneNote**.
101101

102102
In that case, you need to check OneNote's window title with Window spy.
@@ -107,10 +107,10 @@ Window spy will give you about Window Title, Class and Process like:
107107
ahk_class ApplicationFrameWindow
108108
ahk_exe ApplicationFrameHost.exe
109109

110-
If you add any of above lines to VimGroup, vim_ahk works on OneNote.
110+
If you add any of the above lines to VimGroup, vim_ahk works on OneNote.
111111
But if you set `ahk_class ApplicationFrameWindow` or `ahk_exe ApplicationFrameHost.exe`,
112-
vim_ahk also works on other applications which use these Class/Process name
113-
(most of applications installed from Microsoft Store).
112+
vim_ahk also works on other applications which use these Class/Process names
113+
(most of the applications installed from Microsoft Store).
114114

115115
Examples of applications:
116116

@@ -122,8 +122,8 @@ Examples of applications:
122122
## Options
123123

124124
In addition to `VimGroup`,
125-
there are following options which you can set in your script.
126-
All of these can be changed from setting menu, too.
125+
there are the following options that you can set in your script.
126+
All of these can be changed from the setting menu, too.
127127

128128
|Option|Description|Default|
129129
|:-----|:----------|:------|
@@ -158,22 +158,22 @@ add these variable before `Vim := new VimAhk()`.
158158
* VimIconCheckInterval example
159159

160160
If you set VimIconCheckInterval as non-zero, the tray icon is changed
161-
when you change the mode, or change the applications to vim_ahk enabled or not enabled ones.
161+
when you change the mode or change the applications to vim_ahk enabled or not enabled ones.
162162

163163
![trayicon](https://raw.githubusercontent.com/rcmdnk/vim_ahk/master/pictures/trayicon.gif "trayicon")
164164

165165
* Note for VimChangeCaretWidth
166166

167-
Caret width can be changed only on the specific applications: Wordpad, Word, or OneNote.
167+
Caret width can be changed only on specific applications: Wordpad, Word, or OneNote.
168168
On Notepad or Explorer, the caret width is kept but does not change.
169169

170-
For the most of other applications, the caret width is kept as original width.
170+
For most other applications, the caret width is kept as the original width.
171171

172172
When this option is enabled, the current window briefly loses focus when the mode is changed.
173173

174174
## GUI Option Setting Window
175175

176-
You can change these options from the right click menu of task tray icon
176+
You can change these options from the right-click menu of the task tray icon
177177
(find `VimMenu`-`Settings` in the list),
178178
or launch the setting window by `Ctrl-Alt-Shift-v`.
179179

@@ -185,7 +185,7 @@ Here, you can add applications, change the mode change key,
185185
or change the verbose level.
186186

187187
If you push `Reset`, default settings will be shown in the window.
188-
These settings will be enabled only if you push `OK` button.
188+
These settings will be enabled only if you push the `OK` button.
189189

190190
These **default settings** are overwritten by
191191
your `VimXXX` options in your script described above.
@@ -207,13 +207,13 @@ Here are the main modes.
207207
|Mode|Description|
208208
|:---|:----------|
209209
|Insert mode|Original Windows state|
210-
|Normal mode|As in vim, a cursor is moved by hjkl, w, etc... and some vim like commands are available.|
211-
|Visual mode|There are three visual modes: Character-wise, Line-wise, and Block-wise. Block-wise visual mode is valid only for applications which support block-wise selection (such TeraPad).|
212-
|Command mode|Can be used for saving file/quitting.|
210+
|Normal mode|As in vim, a cursor is moved by `hjkl`, `w`, etc... and some vim-like commands are available.|
211+
|Visual mode|There are three visual modes: Character-wise, Line-wise, and Block-wise. Block-wise visual mode is valid only for applications that support block-wise selection (such TeraPad).|
212+
|Command mode|Can be used for saving the file/quitting.|
213213

214214
The initial state is the insert mode, then `ESC` or `Ctrl-[` brings you to the normal mode.
215215

216-
In the normal mode, `i` is the key to be back to the insert mode.
216+
In the normal mode, `i` is the key to being back to the insert mode.
217217

218218
`v`, `V` and `Ctrl-v` are the key to
219219
the Character-wise, the Line-wise, and the Block-wise
@@ -236,8 +236,8 @@ Ctrl-[ switches off IME and enters the normal mode even if IME is on.
236236
Long press ESC (Ctrl-[) will send these original keys, if `VimLongEscNormal` (`VimLongCtrlBracketNormal` is not enabled (0).
237237

238238
If `VimLongEscNormal` (`VimLongCtrlBracketNormal`) is enabled,
239-
single press will send original keys
240-
and long press will change the mode to the normal mode.
239+
a single press will send original keys
240+
and a long press will change the mode to the normal mode.
241241

242242
If using a custom two-letter hotkey to enter the normal mode, the two letters must be different.
243243

@@ -247,7 +247,7 @@ If using a custom two-letter hotkey to enter the normal mode, the two letters mu
247247

248248
|Key/Commands|Function|
249249
|:----------:|:-------|
250-
|i/I/a/A/o/O| Enter the insert mode at under the cursor/start of the line/next to the cursor/end of the line/next line/previous line.|
250+
|i/I/a/A/o/O| Enter the insert mode under the cursor/start of the line/next to the cursor/end of the line/next line/previous line.|
251251
|v/V/Ctrl-v|Enter the visual mode of Character-wise/Line-wise/Block-wise.|
252252
|:|Enter the command line mode|
253253

@@ -260,7 +260,7 @@ If using a custom two-letter hotkey to enter the normal mode, the two letters mu
260260
|Ctrl-a/Ctrl-e| Move to the start/end of the line (emacs like).|
261261
|^| Move to the starting non-whitespace character of the line.|
262262
|w/W| Move to the beginning of the next word.|
263-
|e/E| Move to the end of the next word. (Actually, move to the beggining of the next next word and move a one character left.)|
263+
|e/E| Move to the end of the word. (Actually, move to the beginning of the next word and move one character left.)|
264264
|b/B| Move to the beginning of the previous word.|
265265
|Ctrl-u/Ctrl-d| Go Up/Down 10 line.|
266266
|Ctrl-b/Ctrl-f| PageUp/PageDown.|
@@ -285,6 +285,7 @@ In addition, `Repeat` is also available for some commands.
285285
|C| Cut from here to the end of the line and enter the insert mode.|
286286
|x/X| Delete a character under/before the cursor (not registered in the clipboard).|
287287
|p/P| Paste to the next/current place. If copy/cut was done with the line-wise visual mode, it pastes to the next/current line. Some commands (such yy/dd) also force to paste as line-wise.|
288+
|yiw/diw/ciw| Copy/cut/change current word.|
288289

289290
y/d/c+Move Command can be used, too.
290291
* e.g.) `yw` -> copy next one word.
@@ -297,7 +298,7 @@ y/d/c+Move Command can be used, too.
297298
|u/Ctrl-r| Undo/Redo.|
298299
|r/R| Replace one character/multiple characters.|
299300
|J| Combine two lines.|
300-
|.| It is fixed to do: `Replace a following word with a clipboard` (useful to use with a search).|
301+
|.| It is fixed to do: `Replace the following word with a clipboard` (useful to use with a search).|
301302
|~| Change case.|
302303
|/| Start search (search box will be opened)|
303304
|n/N| Search next/previous (Some applications support only next search)|
@@ -309,27 +310,28 @@ y/d/c+Move Command can be used, too.
309310
|Key/Commands|Function|
310311
|:----------:|:-------|
311312
|ESC/Ctrl-[| Enter the normal mode.|
312-
|Move command| Most of move commands in the normal mode are available.|
313+
|Move command| Most move commands in the normal mode are available.|
313314
|y/d/x/c| Copy/Cut/Cut/Cut and insert (`d`=`x`)|
314-
|Y/D/X/C| Move to the end of line, then Copy/Cut/Cut/Cut and the insert mode (`D`=`X`)|
315+
|Y/D/X/C| Move to the end of the line, then Copy/Cut/Cut/Cut and the insert mode (`D`=`X`)|
316+
|iw| Select the current word.|
315317
|*| Search the selected word.|
316318

317319
## Available commands in the command mode
318320

319321
|Key/Commands|Function|
320322
|:----------:|:-------|
321-
|ESC/Ctrl-[| Enter the the normal mode.|
323+
|ESC/Ctrl-[| Enter the normal mode.|
322324
|w + RETURN| Save |
323325
|w + SPACE | Save as |
324326
|w + q| Save and Quit |
325327
|q | Quit |
326328
|h | Open help of the application|
327329

328-
## Application specific settings
330+
## Application-specific settings
329331

330332
### Q-dir
331333

332-
The keybinds refer to [ranger](https://github.com/ranger/ranger) which is a console file manager with VI key bindings
334+
Refer [ranger](https://github.com/ranger/ranger) which is a console file manager with VI key bindings.
333335

334336
#### Available commands in the normal mode
335337

@@ -343,7 +345,7 @@ The keybinds refer to [ranger](https://github.com/ranger/ranger) which is a cons
343345

344346
Tests are run by executing `tests/run_vimahk_tests.ahk`. A notepad and vim window is opened, and vim_ahk is started.
345347

346-
The testing system used is a series of test cases in `tests/testcases.txt` representing key strokes to send to vim_ahk. These are sent to the open vim and notepad windows, and the resulting text is compared.
348+
The testing system used is a series of test cases in `tests/testcases.txt` representing keystrokes to send to vim_ahk. These are sent to the open vim and notepad windows, and the resulting text is compared.
347349

348350
The tests can be very flakey, so should be used as a guide and to execute code paths to check for errors. Tests should be run with a default ini.
349351

lib/bind/vim_move.ahk

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_")) and (not Vim.State.g)
1+
; Inner mode
2+
#If Vim.IsVimGroup() and ((Vim.State.StrIsInCurrentVimMode("Vim_ydc")) or (Vim.State.IsCurrentVimMode("Vim_VisualChar")))
3+
i::Vim.State.SetInner()
4+
5+
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Inner"))
6+
w::Vim.Move.Inner("w")
7+
+w::Vim.Move.Inner("w")
8+
9+
; gg
10+
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_")) and (not Vim.State.g)
211
g::Vim.State.SetMode("", 1)
12+
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_")) and (Vim.State.g)
13+
g::Vim.Move.Move("g")
314

415
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_"))
516
; 1 character
@@ -31,9 +42,5 @@ b::Vim.Move.Repeat("b")
3142
^f::Vim.Move.Repeat("^f")
3243
; G
3344
+g::Vim.Move.Move("+g")
34-
; gg
35-
#If Vim.IsVimGroup() and (Vim.State.StrIsInCurrentVimMode("Vim_")) and (Vim.State.g)
36-
g::Vim.Move.Move("g")
37-
; }}} Move
3845

3946
#If

lib/vim_ahk.ahk

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
class VimAhk{
2222
__About(){
23-
this.About.Version := "v0.10.0"
24-
this.About.Date := "24/Sep/2021"
23+
this.About.Version := "v0.11.0"
24+
this.About.Date := "24/Jan/2022"
2525
this.About.Author := "rcmdnk"
2626
this.About.Description := "Vim emulation with AutoHotkey, everywhere in Windows."
2727
this.About.Homepage := "https://github.com/rcmdnk/vim_ahk"
@@ -67,11 +67,14 @@ class VimAhk{
6767

6868
; Followings can emulate ^. For others, ^ works as same as 0
6969
GroupAdd, VimCaretMove, ahk_exe notepad.exe ; NotePad
70+
GroupAdd, VimCaretMove, ahk_exe Notepad.exe ; NotePad
7071

7172
; Followings start cursor from the same place after selection.
7273
; Others start right/left (by cursor) point of the selection
7374
GroupAdd, VimCursorSameAfterSelect, ahk_exe notepad.exe ; NotePad
75+
GroupAdd, VimCursorSameAfterSelect, ahk_exe Notepad.exe ; NotePad
7476
GroupAdd, VimCursorSameAfterSelect, ahk_exe explorer.exe ; Explorer
77+
GroupAdd, VimCursorSameAfterSelect, ahk_exe Explorer.exe ; Explorer
7578

7679
; Q-Dir
7780
GroupAdd, VimQdir, ahk_exe Q-Dir_x64.exe ; q-dir
@@ -230,7 +233,9 @@ class VimAhk{
230233
SetDefaultActiveWindows(){
231234
DefaultList := ["ahk_exe Evernote.exe" ; Evernote
232235
, "ahk_exe explorer.exe" ; Explorer
236+
, "ahk_exe Explorer.exe" ; Explorer, Explorer became also upper case, but lower case works for this
233237
, "ahk_exe notepad.exe" ; NotePad
238+
, "ahk_exe Notepad.exe" ; NotePad, Changed as upper case since ~2022/1 ??
234239
, "OneNote" ; OneNote at Windows 10
235240
, "ahk_exe onenote.exe" ; OneNote Desktop
236241
, "ahk_exe ApplicationFrameHost.exe" ; Some Windows applications use this, including OneNote at Windows 10

lib/vim_move.ahk

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
MoveFinalize(){
4444
Send,{Shift Up}
4545
ydc_y := false
46-
if(this.Vim.State.IsCurrentVimMode("Vim_ydc_y")){
46+
if(this.Vim.State.StrIsInCurrentVimMode("ydc_y")){
4747
Clipboard :=
4848
Send, ^c
4949
ClipWait, 1
5050
this.Vim.State.SetMode("Vim_Normal")
5151
ydc_y := true
52-
}else if(this.Vim.State.IsCurrentVimMode("Vim_ydc_d")){
52+
}else if(this.Vim.State.StrIsInCurrentVimMode("ydc_d")){
5353
Clipboard :=
5454
Send, ^x
5555
ClipWait, 1
5656
this.Vim.State.SetMode("Vim_Normal")
57-
}else if(this.Vim.State.IsCurrentVimMode("Vim_ydc_c")){
57+
}else if(this.Vim.State.StrIsInCurrentVimMode("ydc_c")){
5858
Clipboard :=
5959
Send, ^x
6060
ClipWait, 1
@@ -222,4 +222,11 @@
222222
this.Move("")
223223
}
224224
}
225+
226+
Inner(key=""){
227+
if(key == "w"){
228+
this.Move("b", true)
229+
this.Move("w", false)
230+
}
231+
}
225232
}

lib/vim_state.ahk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
;@Ahk2Exe-IgnoreBegin
77
this.CheckModeValue := true
88
;@Ahk2Exe-IgnoreEnd
9-
this.PossibleVimModes := ["Vim_Normal", "Insert", "Replace", "Vim_ydc_y"
10-
, "Vim_ydc_c", "Vim_ydc_d", "Vim_VisualLine", "Vim_VisualFirst"
11-
, "Vim_VisualChar", "Command", "Command_w", "Command_q", "Z", ""
12-
, "r_once", "r_repeat", "Vim_VisualLineFirst"]
9+
this.PossibleVimModes := ["", "Vim_Normal", "Insert", "Replace"
10+
, "Vim_ydc_y" , "Vim_ydc_yInner", "Vim_ydc_c", "Vim_ydc_cInner"
11+
, "Vim_ydc_d" , "Vim_ydc_dInner" , "Vim_VisualLine", "Vim_VisualFirst"
12+
, "Vim_VisualChar", "Vim_VisualLineFirst", "Vim_VisualCharInner"
13+
, "Command" , "Command_w", "Command_q", "Z", "r_once", "r_repeat"]
1314

1415
this.Mode := "Insert"
1516
this.g := 0
@@ -86,6 +87,10 @@
8687
this.SetMode("Vim_Normal")
8788
}
8889

90+
SetInner(){
91+
this.SetMode(this.Mode "Inner")
92+
}
93+
8994
HandleEsc(){
9095
global Vim, VimEscNormal, vimSendEscNormal, VimLongEscNormal
9196
if (!VimEscNormal) {
@@ -103,7 +108,7 @@
103108
Send, {Esc}
104109
}
105110
if (SetNormal) {
106-
Vim.State.SetNormal()
111+
this.SetNormal()
107112
}
108113
if (LongPress){
109114
; Have to ensure the key has been released, otherwise this will get
@@ -127,7 +132,7 @@
127132
Send, ^[
128133
}
129134
if (SetNormal) {
130-
Vim.State.SetNormal()
135+
this.SetNormal()
131136
}
132137
if (LongPress){
133138
KeyWait, [

0 commit comments

Comments
 (0)