Vim Checkbox Toggle

3.8
(75)

Some flavors of Markdown, such as the one implemented by GitHub, support checkboxes that can be in a checked or unchecked state. For example, you can submit a Pull Request to GitHub with Markdown including - [ ] to do item and you will see a checkbox rendered on GitHub, one that you can actually check off when the task is done. If you put an x inside the bracket, it will be rendered as a checked:

- [ ] item
- [ ] another item
- [x] completed item

Whether you’re using Markdown for notes or submitting Pull Requests to GitHub, it’s useful to have a way to toggle a list item as checked or unchecked. The Vim Checkbox plugin does just that.

Once installed, you can run it anytime with <leader>tt. If you’re on a line with a checkbox already, it will toggle the state from checked or unchecked. If you’re on a bulleted list line that does not yet have a checkbox, the mapping will add one.

As a bonus, it even works on a visual selection of lines. You can write a bulleted list, select it, then add checkboxes to every item. As you complete them, use the same mapping to check off items. It works with both style of Markdown bullets, * or -.

Here’s a demo of some of this functionality below:

How useful was this tip?

Average rating 3.8 / 5. Vote count: 75

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts