Skip to content

Instantly share code, notes, and snippets.

@huytd
Created June 15, 2020 08:14
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 huytd/24207623e7eaf161e9611e964648c207 to your computer and use it in GitHub Desktop.
Save huytd/24207623e7eaf161e9611e964648c207 to your computer and use it in GitHub Desktop.
Checkbox for markdown in Vim
syntax match todoCheckbox '\v\s*(-? \[[ x\.!\*]\])' contains=finishedCheckbox,unfinishexCheckbox,flaggedCheckbox,starredCheckbox
syntax match finishedCheckbox '\v(-? \[[ \.]\])' conceal cchar=
syntax match unfinishexCheckbox '\v(-? \[x\])' conceal cchar=
syntax match flaggedCheckbox '\v(-? \[!\])' conceal cchar=
syntax match starredCheckbox '\v(-? \[\*\])' conceal cchar=
hi link todoCheckbox Todo
hi clear Conceal
setlocal cole=1
@huytd
Copy link
Author

huytd commented Jun 15, 2020

Put this in $VIMRC/after/syntax/markdown.vim.

Here's some test content:

- [.] first checkbox item
  - [x] inner list
  - [ ] another inner item
- [x] finished task
- [*] starred task
    - [!] and this is a flagged one

Screenshot:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment