Skip to content

Instantly share code, notes, and snippets.

@codeluggage
Last active May 2, 2022 02:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeluggage/857b944fc503ff9ff8b20cf6d871943f to your computer and use it in GitHub Desktop.
Save codeluggage/857b944fc503ff9ff8b20cf6d871943f to your computer and use it in GitHub Desktop.
How to use shortcuts to work with markdown checkboxes for Dendron

To quickly work with checkboxes in Dendron, you can use these settings and shortcuts.

Setup

  1. Install the most up to date macros extension: https://github.com/ctf0/macros
  2. Install the Vim extension: https://github.com/VSCodeVim/Vim
  3. Add the keybindings below to your keybindings.json
  4. Add the macro definitions below to your settings.json

How to use

  • WIP: ctrl+shift+w to find the next open checkbox and mark it as - [w]
  • Dropped: ctrl+shift+d to find the next open checkbox and mark it as - [d]
  • Blocked: ctrl+shift+d to find the next open checkbox and mark it as - [d]
  • Pending: ctrl+shift+p to find the next open checkbox and mark it as - [y] (is mnemonic - but y is Dendron default)
  • Moved: ctrl+shift+m to find the next open checkbox and mark it as - [m]

Keybindings

    //
    // Quickly work through open checkboxes (`- [ ]`) in current file
    //
    {
        "key": "ctrl+shift+d",
        "command": "macros.insertModeDropTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Insert'",
    },
    {
        "key": "ctrl+shift+d",
        "command": "macros.normalModeDropTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Normal'",
    },
    {
        "key": "ctrl+shift+w",
        "command": "macros.insertModeWipTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Insert'",
    },
    {
        "key": "ctrl+shift+w",
        "command": "macros.normalModeWipTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Normal'",
    },
    {
        "key": "ctrl+shift+y",
        "command": "macros.insertModePendingTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Insert'",
    },
    {
        "key": "ctrl+shift+y",
        "command": "macros.normalModePendingTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Normal'",
    },
    {
        "key": "ctrl+shift+m",
        "command": "macros.insertModeMoveTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Insert'",
    },
    {
        "key": "ctrl+shift+m",
        "command": "macros.normalModeMoveTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Normal'",
    },
    {
        "key": "ctrl+shift+b",
        "command": "macros.insertModeBlockTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Insert'",
    },
    {
        "key": "ctrl+shift+b",
        "command": "macros.normalModeBlockTask",
        "when": "editorTextFocus && editorLangId == 'markdown' && vim.mode == 'Normal'",
    },

Settings

Note: If you already have a "macros.list": { section, you can skip the first and last line of this json:

    "macros.list": {
        "insertModeDropTask": [
            "extension.vim_escape",
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "d"
                }
            },
        ],
        "normalModeDropTask": [
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "d"
                }
            },
        ],
        "insertModeWipTask": [
            "extension.vim_escape",
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w"
                }
            },
        ],
        "normalModeWipTask": [
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w"
                }
            },
        ],
        "insertModePendingTask": [
            "extension.vim_escape",
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "p"
                }
            },
        ],
        "normalModePendingTask": [
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "p"
                }
            },
        ],
        "insertModeMoveTask": [
            "extension.vim_escape",
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "m"
                }
            },
        ],
        "normalModeMoveTask": [
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "m"
                }
            },
        ],
        "insertModeBlockTask": [
            "extension.vim_escape",
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "b"
                }
            },
        ],
        "normalModeBlockTask": [
            {
                "command": "type",
                "args": {
                    "text": "k",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "$",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "/",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "-",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "[",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": " ",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "\n",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "w",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "l",
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "r"
                }
            },
            {
                "command": "type",
                "args": {
                    "text": "b"
                }
            },
        ],
    },
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment