Giter Site home page Giter Site logo

vim_ahk's Introduction

vim_ahk

Setting file/exe file of AutoHotkey for Vim emulation.

vim.ahk is the setting file for AutoHotkey(Autohotkey_L).

vim.exe is a standalone application made from vim.ahk (available in the releases page).

This is vim emulation for Windows. If you are interested in the same settings for Mac, try Vim emulation for Karabiner - Software for macOS: Karabiner-Elements complex_modifications rules by rcmdnk.

Installation

Scripts

If you've already installed AutoHotKey, just open vim.ahk with AutoHotkey.

If you are running AutoHotKey with another script, you can include it in your script using AutoHotKey... Please copy vim.ahk and lib directory in \Users\%username%\Documents or where the script is in, and add the following line in AutoHotkey.ahk or your script:

#Include  %A_LineFile%\..\vim.ahk

at the end of the Auto-execute section.

Executable

You can also use vim_ahk.exe, which can work standalone w/o AutoHotKey.

To get executable, go to the releases page and download the latest zip file.

Unzip the zip file, and place the extracted vim_ahk folder where you like, then launch vim_ahk.exe.

Note

place vim_ahk_icons folder in the same folder with vim_ahk.exe, otherwise, the tray menu icon feature does not work.

Build executable from the source

Clone vim_ahk and go vim_ahk folder, and run build.bat.

  • Double click the file
  • Or run .\build.bat on PowerShell or Command Prompt.

You will find vim_ahk folder which contains vim_ahk.exe and vim_ahk_icons.

Applications (VimGroup)

The default setting enables vim-mode for the following applications:

  • Notepad (メモ帳)
  • Wordpad
  • TeraPad
  • Windows Explorer
  • Thunderbird (only sending window)
  • Microsoft PowerPoint
  • Microsoft Word
  • Evernote
  • Visual Studio Code
  • TexWork
  • TexStudio
  • Q-dir
  • OneNote
  • Applications using ahk_exe ApplicationFrameHost.exe

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

If you want to change applications directly in the script, add VimGroup variable before Vim := new VimAhk() in vim.ahk (Window title/class can be checked by Window spy of AutoHotkey), or write before including vim.ahk

Example line:

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

Multiple applications can be written by a comma-separated.

Note: This will overwrite the default applications. If you want to add these applications to the default applications, add following applications after your applications:

ahk_exe notepad.exe,ahk_exe explorer.exe,ahk_exe wordpad.exe,ahk_exe TeraPad.exe,作成,Write:,ahk_exe POWERPNT.exe,ahk_exe WINWORD.exe,ahk_exe Evernote.exe,ahk_exe Code.exe,ahk_exe onenote.exe,OneNote,ahk_exe texworks.exe,ahk_exe texstudio.exe

Or you can use GUI option setting menu described below.

The default setting of VimSetTitleMatchMode is 2, which makes matching methods as Contain.

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

Note: It may not work on OneNote. OneNote may have a window name like User's Notebook - OneNote, instead of OneNote.

In that case, you need to check OneNote's window title with Window spy.

Window spy will give you about Window Title, Class and Process like:

User's Notebook - OneNote
ahk_class ApplicationFrameWindow
ahk_exe ApplicationFrameHost.exe

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

Examples of applications:

  • Chrome: ahk_exe chrome.exe
  • Firefox: ahk_exe firefox.exe
  • Excel: ahk_exe EXCEL.EXE
  • LibreOffice: ahk_exe soffice.bin (for all LibreOffice applications)

Options

In addition to VimGroup, there are the following options that you can set in your script. All of these can be changed from the setting menu, too.

Option Description Default
VimEscNormal If 1, short press ESC sets the normal mode, while long press ESC sends ESC. 1
VimSendEscNormal If 1, short press ESC send ESC in the normal mode. 0
VimLongEscNormal If 1, short press and long press of ESC behaviors are swapped. 0
VimCtrlBracketToEsc If 1, Ctrl-[ behaves as ESC.
If VimCtrlBracketNormal is 0, Ctrl-[ sends ESC.
If VimCtrlBracketNormal is 1, long press Ctrl-[ sends ESC.
0
VimCtrlBracketNormal If 1, pushing Ctrl-[ sets the normal mode, while long press Ctrl-[ sends Ctrl-[. 1
VimSendCtrlBracketNormal If 1, short press Ctrl-[ send Ctrl-[ in the normal mode. 0
VimLongCtrlBracketNormal If 1, short press and long press of Ctrl-[ behaviors are swapped. 0
VimChangeCaretWidth If 1, check the character under the cursor before an action. Currently this is used for: a in the normal mode (check if the cursor is located at the end of the line). 0
VimRestoreIME If 1, IME status is restored at entering the insert mode. 1
VimJJ If 1, jj changes the mode to the normal mode from the insert mode. 0
VimTwoLetterEsc A list of character pairs to press together during the insert mode to get to the Normal mode.
For example, a value of jf means pressing j and f at the same time will enter the Normal mode.
Multiple combination can be set by separated by ,. (e.g. jf,jk,sd)
VimDisableUnused Disable level of unused keys in other than the insert mode:
  1. Do not disable unused keys
  2. Disable alphabets (+shift) and symbols
  3. Disable all including keys with modifiers (e.g. Ctrl+Z)
3
VimSetTitleMatchMode SetTitleMatchMode:
  1. Start with
  2. Contain
  3. Exact match
  4. Regular expression
2
VimSetTitleMatchModeFS SetTitleMatchMode:
  1. Fast: Text is not detected for such edit control.
  2. Slow: Works for all windows, but slow.
Fast
VimIconCheckInterval Interval to check vim_ahk status (ms) and change tray icon (see below picture).
If it is set to 0, the original AHK icon is set and not changed.
1000
VimVerbose Verbose level:
  1. Nothing.
  2. Minimum tooltip (mode information only).
  3. ToolTip (all information).
  4. Debug mode with a message box, which doesn't disappear automatically.
1
VimAppList Application list usage:
  • All: Enable vim_ahk on all applications (the applicatoin list is ignored).
  • Allow List: Use the application list as an allow list.
  • Deny List: Use the application list as a deny list.
Allow List
VimGroup Applications on witch vim_ahk is enabled. See Applications section

You can add your options before including vim.ahk in your script in the auto execute section like:

VimVerbose := 2
#Include \path\to\vim.ahk

If you want to change them directly in the vim.ahk script, add these variable before Vim := new VimAhk().

Note

VimIconCheckInterval example

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

trayicon

Warning

VimChangeCaretWidth

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

For most other applications, the caret width is kept as the original width.

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

If you enabled this option and change the caret width thick in the Normal mode, and disable the option, the cursor width is kept as thick. To reverse the caret width, re-enable the option and enter the Normal mode at the Wordpad or something to revert the caret width, then disable the option.

GUI Option Setting Window

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

traymenu

settings

Here, you can add applications, change the mode change key, or change the verbose level.

If you push Reset, default settings will be shown in the window. These settings will be enabled only if you push the OK button.

These default settings are overwritten by your VimXXX options in your script described above. (i.e. Reset will restore your options in the script in addition to the default settings of vim_ahk.)

Global shortcut keys

Key Function
Ctrl-Alt-Shift-v Launch GUI Option Setting Window.
Ctrl-Alt-Shift-s Suspend/restart vim_ahk.
Ctrl-Alt-Shift-c Show status check window. (Only on the VimGroup applications.)

Main Modes

Here are the main modes.

Mode Description
Insert mode Original Windows state
Normal mode As in vim, a cursor is moved by hjkl, w, etc... and some vim-like commands are available.
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).
Command mode Can be used for saving the file/quitting.

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

In the normal mode, i is the key to being back to the insert mode.

v, V and Ctrl-v are the key to the Character-wise, the Line-wise, and the Block-wise visual mode, respectively.

After pressing :, a few commands to save/quit are available.

Available commands in the insert mode

Key/Commands Function
ESC/Ctrl-[ Enter the normal mode. Holding (0.5s) these keys emulate normal ESC/Ctrl-[.
jj Enter the normal mode, if enabled.
Custom two letters If two-letter mapping is set.

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 the normal mode even if IME is on.

Long press ESC (Ctrl-[) will send these original keys, if VimLongEscNormal (VimLongCtrlBracketNormal is not enabled (0).

If VimLongEscNormal (VimLongCtrlBracketNormal) is enabled, a single press will send original keys and a long press will change the mode to the normal mode.

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

Available commands in the normal mode

Mode Change

Key/Commands Function
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.
v/V/Ctrl-v Enter the visual mode of Character-wise/Line-wise/Block-wise.
: Enter the command line mode

Move

Key/Commands Function
h/j/k/l Left/Down/Up/Right.
0/$ Move to the start/end of the line.
Ctrl-a/Ctrl-e Move to the start/end of the line (emacs like).
^ Move to the starting non-whitespace character of the line.
w/W Move to the beginning of the next word.
e/E Move to the end of the word. (Actually, move to the beginning of the next word and move one character left.)
b/B Move to the beginning of the previous word.
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.

Example Commands Action
4j Down 4 lines
3w Move 3 words forward
100j Down 100 lines

Yank/Cut(Delete)/Change/Paste

Key/Commands Function
yy, Y Copy the line.
dd Cut the line.
D Cut from here to the end of the line.
cc Change the line (enter the insert mode).
C Cut from here to the end of the line and enter the insert mode.
x/X Delete a character under/before the cursor (not registered in the clipboard).
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.
yiw/diw/ciw Copy/cut/change current word.

y/d/c+Move Command can be used, too.

  • e.g.) yw -> copy next one word.
  • e.g.) d3w -> delete next 3 words.

Others

Key/Commands Function
u/Ctrl-r Undo/Redo.
r/R Replace one character/multiple characters.
J Combine two lines.
. It is fixed to do: Replace the following word with a clipboard (useful to use with a search).
~ Change case.
/ Start search (search box will be opened)
n/N Search next/previous (Some applications support only next search)
* Search the word under the cursor.
ZZ/ZQ Save and Quit/Quit.

Available commands in visual mode

Key/Commands Function
ESC/Ctrl-[ Enter the normal mode.
Move command Most move commands in the normal mode are available.
y/d/x/c Copy/Cut/Cut/Cut and insert (d=x)
Y/D/X/C Move to the end of the line, then Copy/Cut/Cut/Cut and the insert mode (D=X)
iw Select the current word.
* Search the selected word.

Available commands in the command mode

Key/Commands Function
ESC/Ctrl-[ Enter the normal mode.
w + RETURN Save
w + SPACE Save as
w + q Save and Quit
q Quit
h Open help of the application

Application-specific settings

Q-dir

Refer ranger which is a console file manager with VI key bindings.

Available commands in the normal mode

Key/Commands Function
h/j/k/l Backspace(returns to the parent directory)/Down/Up/Enter(enters the selected directory or opens a file)
Alt+u/i/j/k switch between Quad-Directories
' menu Quick-links

Testing

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

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.

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.

References (Japanese)

vim_ahk's People

Contributors

bitdeli-chef avatar bluedrink9 avatar bushnerd avatar joelchretien avatar luciferz2012 avatar mangost avatar nikalas avatar rcmdnk avatar renovate-bot avatar renovate[bot] avatar tenten0213 avatar the-fridge avatar tkishiro avatar willnationsdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim_ahk's Issues

Replace functionality does not currently support uppercase letters

Steps:

  1. Open a document with text.
  2. Attempt to replace a single letter with an upper case letter. In normal mode, type r E.

Expected:
The letter in front of the cursor should be replaced with an upper case E.

Actual:
It is merely added and we are still in replace mode.

Long press <C-[> to return to normal mode, allowing single press to send esc to window

Hello, I just found this script today and I'm loving it. However, I ran into an issue right away.

For those of us who use <C-[> instead of <Esc>, there is no way for us to send esc to the window.

In the settings for vim_ahk, only long-press <Esc> will return you to normal mode.

In Vim, <C-[> is equivalent to <Esc>, so it should do the same things.

:h <Esc>

notation	      meaning	     equivalent	decimal         value(s)	
-----------------------------------------------------------------------
<Esc>	          escape		   CTRL-[	   27	         *escape* *<Esc>*

P.S
In the latest vim_ahk.exe (0.8), icons are not working (Windows 10).

Let's talk refactoring

I just came back to this codebase, and golly it's hard to navigate. It's like doing it fresh all over again, and it reminded me how much we need things like #34.

However, this code needs more than just splitting into files.

The settings UI should be refactored so that each component's data is kept together, and adding new settings should be as simple as calling a single function with the relevant data,
similar to what I did with checkboxes.

Also, why on earth does every single variable start with the word "vim"? This seems seriously unneccessary, especially since the script is titled "vim.ahk". It makes
reading and writing the code harder, and I would like permission to change it.

A lot of the code is a repetition of every mapped key, in a slightly different context. If possible, I want to look into making that a single file to #include, changing some macro
where needed.

Let me know your thoughts. AHK can be brittle to work with, but I think this project should still have enough life left to make taking care of the code worthwhile.

(I hope I'm not coming across too aggressively)

Split script into logically seperated multiple files

Would you consider accepting a PR that refactors out things like UI and settings into different scripts? Folds are ok but it is still unruly trying to jump between different parts of the script or find something you need to check or change, which leads to bugs and forgotten implementations.

Having multiple files #included makes things much clearer to read the project.

For an idea of how this might work, see my fork.

Settings not being saved

When I make changes to the Application list, they are not saved next time I start up the script. When I click About, it says I should have a settings file at $HOME/App Data/Roaming/Auto Hotkey/vim_ahk.ini but there is not one there.

Normal mode 'a' behavior in the end of line

In normal mode, when there is another following line, pressing a in the end of the line will jump to the next line.

Expected behavior is to enter insert mode at the end of current line (same as pressing i here)

For example:

test text
new line.

When cursor is at the end of the first line, after pressing a the cursor will jump to the head of new line.

Let's talk features

Hi,

thanks for this great approach to provide system-wide usage of vim keybindings. After a long journey, I finally found your implementation (though should have been easily found by searching for vim and autohotkey within GitHub). There are some other solutions out there, though, which don't seem as far as your one.

I was wondering if there was a plan for adding some features:

  • show the COMMAND LINE after pressing : . In order to be able to visually adjust the input, the user might be happy to have some kind of feedback.
  • provide application-specific key bindings . As far as I see the code, there is one set of keybindings for each mode over all possible applications. This makes it impossible to include e.g. non-text-applications like mindmaps or other graphically oriented programs (yEd,...). Those applications would require a specific (different) translation for example of "hjkl", fitting to the specific task "go to the right bubble" or "go backwards in time". I could think of adjusting the overall code structure to render it modular in the described sense. New applications could easily be added even with different key bindings.
  • re-implement the functionality in e.g. AutoIt scripting language . As AutoHotKey does not seem to be easily maintainable when the codebase grows and the number of developers join the team, I was thinking of proposing a more "language"-like implementation language like AutoIt. With a clear and concise syntax and better facilities for testing. As the functionality is comparable, this might be an option.
  • integration of a search functionality using / . In order to skim through lange texts without having to switch to the application's native search functionality, a built-in one would be nice. This would be one feature which could profit from a per-application-keybinding (see above), as search / find functionalities mostly differ in applications. Of course, a next step might be the provision of Regular Expressions within the search...
  • ...

I would love to participate in the further development, heading towards a complete vim framework in 2030 ;-) . Therefore, the code structure would have to be modified, today.

Looking forward to hearing from you. What do you think?

Thanks.
Nnako

Shortcut key to disable vim_ahk temporarily

Related to #67

It is useful especially for the visual mode in which users may have some operations with the original shortcut keys.

It can be:

  • Oneshot disabling, i.e. once a key combination is sent then vim_ahk is automatically enabled again.
  • Disable until enabling shortcut key is sent
  • Both?

Maybe it is useful to install such a shotcut key for the all modes.

`e`: move to the last character

currently e move the cursor to the next character of the last character of the word.

aaa bbb| ccc

instead of

aaa bb|b ccc

(this is actually what vim does)

it could be no problem to change (double left) after update of 4473800 ?

Motions only repeat last hotkey

How to reproduce:

  • Open Notepad.
  • Enter insert mode
  • Type: This is a test
  • Enter normal mode
  • Type the motion d4b or alternatively 4db
  • 'test', will be deleted and the cursor will skip to the front of the line. You will now see 'This is a' instead of the expected empty line.

It seems possible to use A_PriorHotkey along with A_Hotkey to enhance the repeat function to match vim's motions.
https://www.autohotkey.com/docs/Variables.htm#A_PriorHotkey

[Feature request] Send ESC by ESC at the insert mode and then enter the normal mode

Using IME for CJK languages when typing pinyin (Roman letters for Japanese), we use number keys to select candidate words and use ESC to cancel the entire input.

1

After pressing ESC there will be nothing left.

However when vim_ahk is running in insert mode, I type some words and I want to press ESC to cancel the input, there are some remaining pinyin like this:

2

So I think is it possible to send ESC at insert mode and then enter the normal mode?

(btw, I found that it works as expected in notepad++ and notepad3, but not working in msword and MATLAB, I don't know why)

e key behaves like w key

In Vim e key takes us the the "end" of the word.

However, in in vim_ahk it takes us to the "start" of word, just like 'w' command

Similarly no difference noted between 'w' & 'W' , 'b' & 'B' etc. ?

Can these be implemented please?

v-mode : selecting texts by moving the cursor (i.e. use key 'l')

Hi ,

thank you for sharing the script.

while using the ahk script in both MS word and Notepad ++, I just realized that
v model + cursor move using key 'hjkl' is not working so well.

for instance, if I put key 'l' in v-mode, I can only select 3 or 4 characters in max (in MS word).
If I put key 'l' longer, then, the word will turn the selected into large 'L' characters.
The same happens in Notepad ++ as well.

any idea?

thanks for your help in advance.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/build_test.yml
  • actions/checkout v4@0ad4b8fadaa221de15dcec353f45205ec38ea70b
  • crazy-max/ghaction-chocolatey v3
  • actions/create-release v1
  • actions/upload-release-asset v1

  • Check this box to trigger a request for Renovate to run again on this repository

Typing cw does not work as expected

Steps to Reproduce:

  1. Open a file with some text in it in MSWord
  2. Navigate to the beginning of a word.
  3. In command mode, type cw.

Expected:
The word under the cursor should disappear, and we should be in insert mode.

Actual:
The word under the cursor is merely highlighted, and we are still in command mode.

Can not change Vim variables (VimGroup, VimRestoreIME, etc...) from an external script once the setting is saved

vim_ahk's setting variables can be set from an external script which includes vim_ahk.

Problem

  • If nothing has been saved, then setting variables in the external script are reflected correctly.
  • If the user opne the setting menu and push Reset, then the settings are changed to the default variables of vim_ahk (not the user definition).
  • After that, even if the user restart the script, user variables in the external script can not be read.

What should be

  • Reset restores settings of the user definition in the external script.
  • Or add Default button to reset to vim_ahk default, and set Reset to restore user variables.

Denylist of applications, instead of Allowlist

Currently VimGroup is the Allowlist.

Some may want to enable vim_ahk for the most of applications
and define the Denylist instead of Allowlist.

  • Maybe just add both list and use each if any of applications are included
  • or add checkbox to choose one of them and have only one application list (setting menu can be simplified)

Force Insert mode in the search modal window

When I search using / in some app (MATLAB in my case), usually a modal window pops up. In this modal window, the mode is still "Normal", whereas it would be more convenient to automatically switch to "Insert" mode in order to enter the search string without additional "i" key.

Placing
VimSetMode("Insert")
just before Return of ; Search {{{ function doesn't fix the problem in my case.

Otherwise, thanks for an excellent script!

Caret in normal mode should go to start of line (or first non-whitespace character)

Steps to Reproduce:

  1. Open a file with more than one line.
  2. In normal mode, type a ^ (caret character).

Expected:
It should go to the start of the line (or first non-whitespace character)

Actual:
In the current behavior, it goes to the end of the first word on the following line.

Workaround:
Since there is no way to get the feedback on where you are within the line (i.e. whitespace char or non-whitespace char), it should probably follow the behavior of typing 0 in normal mode as a fallback.

How can I make this work for SSMS? it used to work until now

your branch of vim.ahk is great and I used to use it on SSMS but today it won't recognize the window. The title of the tab is SQLQuery.sql which is default but when I put that in the vim.ahk settings, it doesn't recognize the window. It works to recognize OneNote and other windows but now this application. Any ideas on how to make it work? is there a way to make the settings recognize "startswith(SQLQuery)" for example?

J Join behaving strangely

If we have 3 lines:

a
b
c

And the cursor is on line b, and I press J. In Vim it would do:

a
b c

But here it does

a b
c

Not a big issue - just thought I'd add it :-) Thanks again.

Issues on VimChangeCaretWidth

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

For the most of other applications, the caret width is kept as original width.

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

  • Enable on other applications (maybe need to use another method, specific on applications or?)
  • Revert the width when the forcus is changed to the vim_ahk disabled applications

use CheckChr, BlockInput for some places

  • maybe good to inser a short sleep after change the mode (sometime the key after the change to the normal mode is inserted)
  • short sleep after h/j/k/l
  • check the last line (line copy, some movement (g?)
  • word jump (w/W/e/E/b/B) may work better by cheking the current (or next) character (?)
  • jump to the end of the line: at vim, it is the one character before the end of the line

Cannot coorperate with my Cap-Esc blinding stript

does anyone know how to blind Cap with Esc that make life much easier ?? because it cannot work with my own stript by just adding a "#Include %A_LineFile%..\vim.ahk" , which is very distressing, my own stript below:

#Include %A_LineFile%\..\vim.ahk

g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false


*CapsLock::
    if (g_ControlRepeatDetected)
    {
        return
    }

    send,{Ctrl down}
    g_LastCtrlKeyDownTime := A_TickCount
    g_AbortSendEsc := false
    g_ControlRepeatDetected := true

    return

*CapsLock Up::
    send,{Ctrl up}
    g_ControlRepeatDetected := false
    if (g_AbortSendEsc)
    {
        return
    }
    current_time := A_TickCount
    time_elapsed := current_time - g_LastCtrlKeyDownTime
    if (time_elapsed <= 250)
    {
        SendInput {Esc}
    }
    return



*LCtrl::CapsLock


~*^a::
~*^b::
~*^c::
~*^d::
~*^e::
~*^f::
~*^g::
~*^h::
~*^i::
~*^j::
~*^k::
~*^l::
~*^m::
~*^n::
~*^o::
~*^p::
~*^q::
~*^r::
~*^s::
~*^t::
~*^u::
~*^v::
~*^w::
~*^x::
~*^y::
~*^z::
~*^1::
~*^2::
~*^3::
~*^4::
~*^5::
~*^6::
~*^7::
~*^8::
~*^9::
~*^0::
~*^Space::
~*^Backspace::
~*^Delete::
~*^Insert::
~*^Home::
~*^End::
~*^PgUp::
~*^PgDn::
~*^Tab::
~*^Return::
~*^,::
~*^.::
~*^/::
~*^;::
~*^'::
~*^[::
~*^]::
~*^\::
~*^-::
~*^=::
~*^`::
~*^F1::
~*^F2::
~*^F3::
~*^F4::
~*^F5::
~*^F6::
~*^F7::
~*^F8::
~*^F9::
~*^F10::
~*^F11::
~*^F12::
    g_AbortSendEsc := true
    return

it will work when adding on the top, but then , i still need to usethe origin "Esc" in the left top to goto normal mode.
Looks like rather it cannot work, or they just work individually. i am confusing.

Automatic detect Textbox

I just wander that could you supports detect when clicking to a textbox of any Windows apps? My wish is I want to use terminal bindkey when typing in textbox. For example, Ctrl + E = End, Ctrl + A A = Home...

ctrl-w in insert mode to delete the previous word

I just installed the script and so far I am very pleased with the script.
I am very used to vim key bindings and I frequently use ctrl-w in insert mode to delete the previous word.

In MS Word for example Ctrl-W closes the Window. I am asking you if it would be possible to implement deleting the previous word instead or is it impossible to overwrite default Windows key bindings?

If it is possible I might have a look at implementing it myself.

Thanks already.
Stefan

'dd' command

Hi,

Thank you for sharing your script. It works perfect with my ten-less keyboard. :-)

In the mean time, I found that when I use 'dd' - cut a line in my MS word,
the cursor also deletes the first letter of the next line.

do you have any idea how I can fix this problem?

thank you for your help in advance.

Best Regards

Eucman

[Feature request]: Changing text cursor (caret/vertical line) to indicate current mode

Hello everyone! First, thank you for such an awesome program! I forked it to suit a particular program and it's been wonderful. However, sometimes it's rather troublesome having to peek at the lower right corner to see which mode I'm in.

In Vim, a block cursor means Normal mode; a line means Insert mode. Is it possible to implement the same behavior for vim_ahk?

I googled a bit and I think it involves DllCall() This (source) works in changing the mouse cursor:

Cursor = %A_ScriptDir%\LocationOfACursor.ani
CursorHandle := DllCall( "LoadCursorFromFile", Str,Cursor )
Cursors = 32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651
Loop, Parse, Cursors, `,
{
	DllCall( "SetSystemCursor", Uint,CursorHandle, Int,A_Loopfield )
}

MsgBox, Test now!
SPI_SETCURSORS := 0x57
DllCall( "SystemParametersInfo", UInt,SPI_SETCURSORS, UInt,0, UInt,0, UInt,0 ) ; Reload the system cursors
return

Possible pointers:
https://docs.microsoft.com/en-us/windows/win32/menurc/carets

Any help is much appreciated. Thank you!

[Enhancement] Visual indicator of normal/insert mode (not in notification tray)

I hide my taskbar, so it becomes hard to know which mode I'm in. Is there a way to show the normal/insert mode status outside of the notification tray?

I tried making my own Vim emulation with ahk, and while I abandoned it due to this one being much more fully featured, one thing I did do was have a visual indicator of status. In my Vim emulation attempt, I used CapsLock as my mode indicator and toggle, and I used the following simplistic code to show the state.

Would it be possible to integrate something like this into vim_ahk? I haven't looked at vim_ahk's source, so if you think it's possible, but can't devote the resources, could you please point me to the code or logic that would be useful in implementing this. Thanks, the program is great so far in my limited testing.

#SingleInstance force
#NoEnv

Menu, Tray, NoStandard
Menu, Tray, Add, Exit, QuitScript


Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption +LastFound
Gui, Font, caf001e s12 bold, Verdana ;changes font color, size and font
Gui, Color, af001d ; changes background color
Gui, Add, Text, ,CAPS LOCK ON
WinSet, TransColor,af001d

Loop
{
	GetKeyState, CapsState, CapsLock, T
	If CapsState = D
	{
		Gui, Show, % "x" . (A_ScreenWidth/1.2) . "y" . (A_ScreenHeight/1.1) . " NoActivate"		Menu, Tray, Icon
	}
	Else
	{
		Gui,  hide
	}
	Sleep, 100
}

QuitScript:
ExitApp
return

Can't build it for myself

Hi,

I tried to build it for myself, but I got the error message I attach:

image

Also, when I try to run vim.ahk, I get something similar. What can cause this problem?

Using "O" for new line always enters a tab to what ever word is on that line - can this be changed?

First I'm new to understanding ahk so if this is an easy fix I appologize.

Example:
This is the line one.
This is the line two.

Given that my cursor is anywhere on line two,
And I press shift+o to give a capital "O"
Then the cursor should create a new blank line above line two and shift line two down making it line three.

Instead when I press "O" it shifts line two down to line three but places the cursor on line three followed by a tab then the text for line three. Line two at this stage is blank. Then I have to delete the tab character, change to normal mode and go up to line two then press "i" to start insert mode.

Is there a way to change this behavior so that it shifts line two down to line three with no tabs in front, then places the cursor on line two at the beginning of the line and be in insert mode?

please let me to be contributor

Hi, thank you for your great project, I add a feature to this project.
supporting jj and تت instead of pressing Esc in both English and Farsi languages.
I can't push them to your git, I built a new branch, you can see it and if you want then you can merge it
with your master branch.
best regard.

vim_ahk blocks keys used only by other AHK script

I use another AHK script called bug.n for window management. All the window-management hotkeys use a Windows-key combination, i.e. #j, #k, etc. I don't think vim_ahk uses these combinations for anything, but in "normal mode", it seems to be blocking them from reaching the bug.n script. If I switch to insert mode, the bug.n hotkeys work fine.

Any ideas how I could let any the Windows-key+letter combinations pass through to bug.n, regardless of what vim_ahk mode I'm in?

default app level keyboard shortcut not working under visual mode

Thanks so much for the contribution. I love it overall. I do have an issue with triggering some useful keyboard shortcuts that originally comes with some apps. for example, in PowerPoint, if I select a word using the following vim command 'vw'. It goes from normal to visual mode as expected. However, If I now want to bold the selected text by pressing 'Ctrl + b', it doesn't work as expected. I believe it works under normal mode if I choose to ignore all unused keys in your setting. but there is no such corresponding setting under visual mode. Can you please enable that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.