Skip to main content
Updated motivation
Source Link
llinfeng
  • 352
  • 2
  • 14

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.

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.

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.

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.

Source Link
llinfeng
  • 352
  • 2
  • 14

May I have a Vim session report its "Mode" in its "Window Title"?

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: enter image description here

    • Window Title: [No Name] - - GVIM1
    • win-class name: Xming X
    • Process Name: Xming.exe
  • 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 OR Filename -- GVIM1 - Normal-mode, depending on the current state of Vim.

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 :)