hook global WinSetOption filetype=(markdown) %{ map buffer normal ": enter-user-mode markdown-menu" } # A menu for common markdown actions declare-user-mode markdown-menu map -docstring "Toggle the checkboxes on the same line" global markdown-menu t ": markdown-toggle-checkbox" define-command -hidden markdown-toggle-checkbox %{ try %{ execute-keys -draft "s^\s*- \[( |x)\]h: markdown-toggle-checkbox-selections" } } define-command -hidden markdown-toggle-checkbox-selections %{ try %{ execute-keys -draft -itersel ": markdown-toggle-checkbox-one" } } define-command -hidden markdown-toggle-checkbox-one %{ try %{ execute-keys -draft "sxr " } catch %{ execute-keys -draft "s rx" } }