Clarification of the moving parts
First, let me clarify what I mean by "Window Title", and what I expect to achieve
On Windows OS, GUI programs will have three attributes: its Window Title texts, the process.exe name and its win-class name. An example of Gvim ran through Xming looks like the following:
- Window Title:
[No Name] - - GVIM1
- win-class name:
Xming X
- Process Name:
Xming.exe
- Window Title:
I am looking for a way to start Vim, so that:
- Instead of reporting
FileName -- GVIM1
as its "Win-Title", it also reports, either: Filename -- GVIM1 - Insert-mode
ORFilename -- GVIM1 - Normal-mode
, depending on the current state of Vim.
- Instead of reporting
Please advise if there is a better way to have Vim dynamically update its "Title".
Explanation
At the end of the day, I would like to detect the precise Vim mode through its "Window Title". This opens new doors for re-mapping indistinguishable pairs of keys, like <tab>
and <c-i>
.
For example, through AutoHotKey, which runs on Windows OS, I can happily assign <tab>
(in normal mode) to a particular command-line function, while keeping <c-i>
behaving "normally" (go to the next position on the jump list). AutoHotKey detects WinTitle by default and will need a lot more effort to conduct real-time OCR on the dynamic Window of Gvim, to tell its current mode. Blindly remapping the <tab>
key will distort the normal usage of <tab>
key in Insert-mode.
Please advise if this is achievable, as it is funny to learn that <tab>
and <c-i>
are identical keys in the year 2019 :)
Motivation and cross-reference (TL;DR)
Things start from this post about Vimwiki, where I re-learned that <c-i>
and <tab>
are indistinguishable by the Modern Vim. This brings conflict in my hard-to-change muscle memory. For the mappings in normal mode:
<c-i>
should take me to the more recent position in the jump list (opposite of<c-o>
), and<tab>
should handle its own business:- For Vimwiki,
<tab>
jumps to the next hyperlink, and<s-tab>
jumps to the previous hyperlink - For other filetypes, I do not press
<tab>
key in normal mode.
- For Vimwiki,
I tend to spend a considerable amount of time in Markdown documents, and I rely on Vimwiki to nativage the stacks of Markdown files. (I maintain two websites + one personal wiki with more than 2,000 entires.)
At the end of the day, I would like to "split" the functionality of <tab>
and <c-i>
==> In Normal-mode, pressing <tab>
shall issue :VimwikiNextLink<CR>
and <c-i>
shall bring me to the next point in the Jump list.
Since it is well established that <tab>
and <c-i>
are treated alike by Vim, I am planning to use AutoHotKey to overwrite the <tab>
key only in Normal Mode. This is where all dots should connect: through a title-matching trick in AutoHotKey, <tab>
is only mapped to :VimwikiNextLink<CR>
in normal mode.
Given the tweak on the titlestring
option, I see the light of distinguishing modes.
<tab>
and<C-i>
separately? I don't know what you're trying to do, but this seems really convoluted. It's probably going to be simpler to pick a different mapping, or maybe use an<expr>
mapping. (Also for the record, tab andC-i
are indistinguishable because they're literally the same ASCII value, 0x09)<tab>
key in normal mode, and leave<c-i>
untouched. Thus, the two keys are then distinguished. Let me update my original post for the missing motivation piece.titlestring
.