Reputation: 1395
Terminals, due to historical reasons, won't distinguish tab from Ctrl+I. This makes quite a mess when I use Vim: my muscle memory tells me that Ctrl+I shall advance me forward to the next position in the "Jumplist", but some Vim-plugins do remap the tab key to do other good stuffs.
Can I make a "conditional mapping" for active windows from ahk_process gvim.exe
when no "special characters" are shown at the bottom left corner of the active Window?
At the end of the days, I would like to map the tab key only in "Normal-mode". The best that I can come up with is to OCR a fixed region of pixels at the buttom-left corner, and make it a conditional. Yet, I am inexperienced for getting OCR jobs done in AHK.
Sidenote: I am asking for help from the Vim community the flipside of the same question: https://vi.stackexchange.com/questions/18796/may-i-have-a-vim-session-report-its-mode-in-its-window-title
Upvotes: 0
Views: 233
Reputation: 172510
There's no need to grab Vim's current mode to make it available to another application; that would be really cumbersome. If your eventual goal is to send different keys for <Tab>
/ <C-i>
to Vim (e.g. <F13>
instead of <Tab>
), and you only want Vim to react differently in certain modes (e.g. normal mode), you can just map the other modes to again unify both keys:
:nnoremap <F13> ... " Functionality A
:nnoremap <C-i> ... " Functionality B
:map! <F13> <C-i> " Both keys continue to do the same in insert and command-line mode.
Upvotes: 2
Reputation: 198304
No need for OCR/AHK hacks.
:nmap
(and :nnoremap
) maps only in normal mode.
:imap
(and :inoremap
) maps only in insert mode.
etc.
See :help :map-commands
for the variety of different mapping commands for variety of modes.
If a plugin is overwriting a normal-mode mapping for Tab, see who the offender is by using :verbose nmap <Tab>
(or its equivalent, :verbose nmap <C-I>
), then look at its documentation to see how to rebind it (or in the worst case, eliminate the culprit).
Upvotes: 2