                     This.KeyList[k] := This.KeyList[k] ? This.KeyList[k] + 1 : 1
                 }
                 ;This.KeyList[0] := idx
-                If Not Hotkey_OK {
+                if Not Hotkey_OK {
                     For i , k IN _SaveList
                     {
                         This.KeyList[k] := This.KeyList[k] - 1
-                        If This.KeyList[k] = 0 {
-                            Hotkey,%k%,off
-                        }
-                    }
-                }
-                Else {
+                        if This.KeyList[k] = 0 {
+                            Hotkey, %k%, off
+                        }
+                    }
+                }
+                else {
                     This.KeyBody[mkey] := label
-                    If not RegExMatch(This.KeyString,"\t" This.ToMatch(mKey) "[^\t]*")
+                    if not RegExMatch(This.KeyString, "\t" This.ToMatch(mKey) "[^\t]*")
                         This.KeyString .= A_Tab mKey A_Tab
                 }
             }

        ShowComment()
    }

	sMap(key,label,win=""){
		This.UseHotkey[key] := True
    	this.Map(key,label,win)
	}
    Map(key,label,win="") {
		If not RegExMatch(Key,"[^\s]")
			return
        if Strlen(win) = 0
            w := This.vimGlobal
        Else
            w := This.vimWindows[win]
        If not w.winVaild
        {
            w := new This.vimClass(win)
            This.vimWindows[win] := w
        }
        mode := w.GetMode()
        mode.SetHotkey(key,label)
    }

    Comment(action,desc,complex=1) {
        This.CommentList[action] := desc
        This.CommentType[action] := complex
    }

    do() {
        WinGetClass,win,A
        w := This.Vaild(win)
		m := w.GetMode()
		If This.ExcludeList[win] And not this.UseHotkey[m.GetThisHotkey()]
		{
			Send,% m.TransSendKey(A_ThisHotkey)
			return
		}
        If w.winVaild {
            mode := w.GetMode()
			If Mode.KeyList[A_ThisHotkey]
            	mode.Try()
			Else
			{
				w := This.vimGlobal
				mode := w.GetMode()
				mode.Try()
			}
        }
    }

	Filter(String) {

        WinGetClass,win,A

		If This.ExcludeList[win]
			return
        w := This.Vaild(win)

        If w.winVaild {
            mode := w.GetMode()
			mode.query(string)
        }
    }

	Exclude(win) {
		This.ExcludeList[win] := True
	}

	Include(win) {
		This.ExcludeList[win] := False
	}


    ListKey(win="",mode="") {
        w := This.Vaild(win)
        If strlen(mode) {
            m := w.winmode[mode]
            For k , l in m.KeyBody
                msg .= k "  " l "`n"
            return msg
        }
        Else {
            For n , m  in w.winMode
            {
                msg .= "====`n" n "`n----`n"

﻿/*
API 函数列表：
vim.mode("模式", "ahk_class")  ; 设置运行的模式
vim.map("热键", "Label标签", "ahk_class")  ;映射热键
vim.settimeout("按键超时时间", "ahk_class")  ;设置按键超时时间
vim.listkey("ahk_class")  ;显示所有映射的热键体
vim.control("on/off", "ahk_class")  ;启用/禁用映射的热键
vim.comment("标签", "描述", "是否允许多次运行（0/1)")
内置Label:
<Repeat> 重复上一次动作
*/

#UseHook On
Setkeydelay, -1
return

; 此函数可以根据自己的喜好进行修改
ShowComment(more="") {
    if not ToShowComment
        return

    WinGetClass, win, A
    w := vim.Vaild(win)
    mode := w.GetMode()
    msg := mode.KeyTemp "`n=============================`n"
    ;GUIControl, , Edit1, %msg%

    if Strlen(more)
    {
        Loop, Parse, more, `n
        {
            key := Trim(A_LoopField)
            action := mode.KeyBody[key]
            ;comment := vim.CommentList[action]
            comment := GetCommentDest(action)
            if Strlen(comment)
                msg .= key "  >>  " comment "`n"
            else
                msg .= key "  >>  " action "`n"

        }
        Tooltip % msg
        ;GUI, VIMINFO:Show
    }
    else
        Tooltip
        ;GUI, VIMINFO:Show, Hide
}


