一千萬個為什麽

搜索

Vim停止將“<Plug>”視為關鍵字以在插入模式下調用函數

我在我的vimrc文件以下配置。

inoremap  InsertComment

在我定義的vim​​文件夾中的某個地方

inoremap  InsertComment :call INSERT_MY_COMMENT

The mapping worked really well after I configured it. But somehow recently it stopped functioning. And whenever I can to use the Key-bind in the insert mode, instead calling the function that I mapped, vim will just paste the entire InsertComment thing to my buffer.

我試圖調試,發現如果我映射

inoremap :call INSERT_MY_COMMENT

it still works as desired, which means there must be something wrong with the part.

But I really have no clue on why would stop being interpreted by vim as a handle to call other plugins.

我還嘗試手動復制和粘貼

inoremap  InsertComment :call INSERT_MY_COMMENT
inoremap  InsertComment

在vim的命令行中,只是為了確保配置沒有被意外取消。但是,vim仍然不接受它作為一個函數,而是將純文本復制到緩沖區。

最佳答案

你的問題是你正在使用

inoremap  InsertComment

這基本上意味著,映射鍵的遞歸分辨率阻止,這通常不是您想要的。因此,將映射更改為

imap  InsertComment

See also the extensive help

(從以 MAPPING 開頭的段落開始閱讀)

轉載註明原文: Vim停止將“<Plug>”視為關鍵字以在插入模式下調用函數